Introduction
In this article you will see how to use a "For Each" loop in a NINTEX workflow. I will add multiple users to the specified group by calling the web service "_vti_bin/usergroup.asmx". I have created a custom list named "User Collection" that has the following columns:
- Group Name: A single line of text: It stores the group name to which the users will be added.
- Users: Person or group; multiple users can be added to this column that will be added to the specified group.
Workflow Design

A Regular Expression action is used to get the user collection from the list item and stores it in the Collection workflow variable. A "For Each" action is used to loop through all the users from the collection variable and store it in a person or group workflow variable. Call the web service action used to add the users to the specified group.
Add users to group workflow
Use the following procedure to add users to a group workflow:
- Navigate to the User Collection list.
- Click on the "List" tab and then click on "Workflow Settings".
- Click on "Create a Workflow in Nintex Workflow".

- Click on "Cancel".

- Drag and drop the "Regular Expression" action from the "Operations" section.

- Click on the "Configure from Regular Expression" drop down list.
- Click on the "Variables" button in the ribbon interface.

- Click on the "New" button.
- Enter the Name as "userCollection" and variable type as "Collection".
- Click on "Save".

- The workflow variable is created successfully.
- Click on "Close".
- Get all the users from the list item and separate the values by a semicolon. Store all the users in the collection variable that we have created.

- Click on "Save".
- Drag and drop the "For Each" action from the "Logic and flow" section.

- Click on "Configure" from the "For Each" drop down list.
- Click on the "Variables" button in the ribbon interface.
- Click on the "New" button.
- Enter the Name as "user" and the variable type as Person or Group.
- Click on "Save".
- The Workflow variable is created successfully.
- Click on "Close".
- Drag and drop the "Call web service" action from the Integration section inside the "For Each" action.
- Click on "Configure" from the drop down list in the "Call web service" action.
- Click on the "Insert Reference" button for the URL column and then click on the "Common" tab. Select "Web URL" and then click on "Ok".

- Append "/_vti_bin/usergroup.asmx" in the URL column.
- Enter the User Name and Password to call the web service and then click on the "Reference" button.
- Click on "Ok".

- All the web service methods will be populated. Select the "AddUserToGroup" web method that will be used to add the users to the specified SharePoint group.

- The Web Service Input section will be populated for passing the input values to the web method.

- Click on the "Insert Reference" button for the groupName column and then click on "Item Properties" tab. Select the Group Name and then click on "Ok".
- Click on the "Insert Reference" button for the userName column and then click on the "Workflow Variables" tab. Select the user and then click on "Ok".

- Click on "Save".







Chintan DesaiPosted Oct 5, 2015, 2:06 AM
Wonderfully shown For...Each. Can you update your step 32 and correct column from userName to userLoginName.
Navneet MathurPosted Nov 20, 2013, 3:05 PM
Nice article but I think you skipped the part of actually configuring the "for each loop". In that section, you go directly into configuring the web service.