1

I am working on sharepoint server 2013 enterprise. and inside sharepoint designer 2013 & workflow 2010, i am trying to implement the following senario:-

  1. I got a list workflow that get fired when an item is created.
  2. I want to check if the user who created the item (which is the same as WorkflowContext:current User) belong to a sharepoint security group, If so to set a site column named Team to be equal = CM

  3. and if the user does not belong to set the Team= IT.

here is my list workflow:- enter image description here

I thought that the above will might work in a way or another but it did not. so can anyone adivce on this please?

i also tried using "created by" as follow, but did not work either:-

enter image description here

1

Unfortunately , In SharePoint workflow platform 2013 and 2010, there is no OOTB action to check if the user belongs to a specific group.

Meanwhile, You can do this

  • In SharePoint workflow 2013 via REST or via loop as a workaround.
  • But Unfortunately , in SharePoint Workflow 2010 you only can build your own custom workflow activities.

Note : Don't try to check this solution http://spdactivities.codeplex.com/ I am pretty sure it's not working for SharePoint 2013.

My suggestion : No need for workflow at this section , try to build Event Receiver to update directly your team column based on the group of the current user as the following

SPSecurity.RunWithElevatedPrivileges(delegate(){
         using (SPSite site = new SPSite(properties.SiteId))
            {
             using (SPWeb web = site.OpenWeb(properties.Web.ID))
               {

                  SPUser user = properties.Web.CurrentUser;
                   SPGroup group = web.SiteGroups[GroupName];

                                    if (!user.InGroup(group))
                                    {
                                        // update the list item
                                    }
                 }
                }
               }

  // ٍSEARCH USER WITHIN GROUP  
  public static bool InGroup(this SPUser User, string GroupName)
    {
        return User.Groups.Cast<SPGroup>().Any(g => g.Name.ToLower() == GroupName.ToLower());
    }  

For more details about event receiver checks What are the differences btw "properties.Web.CurrentUser;" & "web.Users.GetByID(properties.CurrentUserId);" inside my Event Receiver

  • thanks for lot for your reply. but can you please advice on these 2 points; 1) I found this link which allow to have the option inside designer workflow to check if a user exists inside SP group as mentioned here spdactivities.codeplex.com and seems it works with SP2013. 2) second point you mentioned to use a Event receiver, but as i did not write a event receiver before so can you please provide some general guide on what type of event receiver i need to create to achieve my requirement ? – john Gu Oct 3 '16 at 12:07
  • 1
    Hi @johnG , regarding the first point , before I answered this question , I downloaded the package from spdactivities.codeplex.com because it's what you need and may help you , but unfortunately it's not worked for SharePoint 2013 , it requires WSS.30. also, you can try this with yourself as a double check , but I am sure it's not worked ! , also the last version was released since 2008 . Regarding the Second point let me send to you step by step guide to can do this , and please tell me if you need more clarification – Mohamed El-Qassas MVP Oct 3 '16 at 12:18
  • 1
    Dear @johnG , please check this link to know How to create Event Receiver Step by Step youtube.com/watch?v=wZf2xvEM5Io and c-sharpcorner.com/uploadfile/5b1f04/… Please don't hesitate to tell me if you stopped at a any step – Mohamed El-Qassas MVP Oct 3 '16 at 12:23
  • thanks a lot for the link. so mainly i will need to create a farm solution>>add new event receiver of type "List item events".. which fires when item was added.. now in my case i have 11 sub-sites, and each sub-site contain 4 issue tracking lists. so if i were to create this using sharepoint designer workflow, i will go to each sub-site and inside the related list will add the workflow.. – john Gu Oct 3 '16 at 12:46
  • but not sure how i can map this inside my event receiver, as on each sub-site i need to check for different SP group,, so i mainly need 11 event receiver,, and also i do not want the event receiver to fire on all the subsites lists,, i need it to fire on one list inside each sub site,, so where i can define these settings? – john Gu Oct 3 '16 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.