Skip to main content

Scenario:

On K2 form, a requester enters multiple users in SP field that is designd to store multiple users. Workflow is supposed to

- Read those users

- Create a SP group and all of those users to SP group.

 

This is what I did in Workflow:

1. Read user from SP list and create a user reference using the email ID of user

2. Create a SP group

3. Add user reference to SP group (that was created in step#2 above)

 

This works fine when requester specifies ONLY one user but not when they specify more than users.

 

How can I assign multiple users to SP group in Workflow?

Thanks!

Hi K2_Beginner,

 

lets suppose your k2 form field is returning list of multiple users in string format  "user1; User2; User3"

 

In your WorkFlow First use an activity to create a group. 

 

Once this activity is complited move to next activity  which will use for eachloop.

 

For NextItem outcome of forEachLoop add another activity having event "SharePoint User Management Wizard" this will add your users one by one to created group.

 

And after adding these user if you have any activity  attach that in "No more Items" outcome 

 

 

 

you can refer below links for more info on foreach Wizard and  SharePoint User Management Wizard. 

 

 


Just came back from vacation. Thank you!! I will give it a try.


Hello Kran,

I tried but it would add only the first user. Basically my logic is.

1. Get Group Reference

2. Open a "for each" loop for SP column containing users.

3. For each user get user reference by email

4. Assign user reference to group reference.

 

I am positive for each user it's looping through but adds only the first user. What I am doing wrong?

 


Hi K2_Beginner,

 

your loop is correct but can you please confirm what data  Member(Email) is storing in data field  Email_Field. This you can check by "Process Overview Report" whcich is available under K2 Workspace.


Since I am using SharePoint Designer, data audit doesn't work. But in View Workflow, I can see value of field Email_Field, it shows emails for both the users. I also added a new step in loop to update a different data field (Email_in_Loop). It gets updated in each iteration with the email address that For-loop is returning. It shows both email addresses with loop index. So it did loop through all the users.

 

 

 


Hi K2_Beginner,

 

      Please check if user is available in sharepoint  site, if not please add user there. Incase user is aready available there please share K2 logs. 


Yes, both the users are in subsite. There are some errors related to SP groups. But these groups are not being used in workflow

 

 

"39568710","2017-03-09 10:54:19","Error","IdentityService","64005","ResolvingException","IdentityService.ProviderCacheIdentity:GroupProvider.GetGroup","64005 Failed to resolve 'SP:XXXXX Business Unit SitesAD2 Group': Group cannot be found..","anonymous","0.0.0.0","XXXXX:D:Program Files (x86)K2 blackpearlHost ServerBin","39568710","9b82f483d0254e96a17e58ded8157256",""
"39568717","2017-03-09 10:54:19","Error","General","0","ErrorMessage","1","0 SharePointRoleProvider.GetGroups: System.Reflection.TargetInvocationException: An unexpected failure was encountered when contacting SharePoint to get information from the group provider Sensus Business Unit Sites: Group cannot be found. ---> System.Exception: Group cannot be found.
   at SourceCode.SharePoint15.Client.GroupFunctions.LoadGroup(Group group, Boolean throwException)
   at SourceCode.Security.Providers.SharePoint.Shared.SPCsomClient.SourceCode.Security.Providers.SharePoint.Shared.ISPGroupProviderClient.GetGroup(String groupName)


Hi,

 

I would troubleshoot this issue with following steps. You are already saving the email ID in a data field in for each loop to check if for each loop returning data in each iteration.

1. There might be an issue with user management event. Try adding email event in for each and check if it is sending an email to all users.

If it is sending an email there might be an issue with user management event.

2. Instead of using an email ID from reference field. Save that email ID to a data field in a loop, which you are already doing and use that data field in user management event.

3. Try with multiple users. I had an issue with for each loop. It was missing alternative element in the collection while iterating.

4. Alos, you can try adding delay for user management event, SharePoint might be taking time internally to resolve the user and then adding in a group. I am not sure if you do it in K2 designer for SharePoint.

5. You can try extracting a workflow and opening in K2 studio or visual studio. There you get more freedom to play around it.

Let me know if it helps you.

 


Reply