How to Use For Each Loop in NINTEX Workflow

Updated: Mar 18, 2019

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:

  1. Group Name: A single line of text: It stores the group name to which the users will be added.

  2. 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".


Publish the workflow

1. Click on the "Publish" button in the ribbon interface.


2. Ensure the Title is set; optionally you can set the values for Description and Change Comments.


3. Click on the "Submit" button.


4. The workflow is published successfully.


Test the workflow

1. Navigate to the User Collection list.

2. Create a new item.


3. Select the item and then click on Workflows in the ribbon interface.

4. Click on "Add users to group workflow" and then click on the "Start" button.

5. After a few minutes the workflow status will be changed to "Completed".Users are added successfully to the specified group.


Summary

Thus in this article you saw how to use a "For Each" loop using a NINTEX workflow.

Related Links

  1. How to Create Site Using NINTEX Workflow in SharePoint

  2. How to Delete Site Using NINTEX Workflow in SharePoint

  3. How to add user to SharePoint group using NINTEX workflow

  4. How to Remove User From SharePoint Group Using NINTEX Workflow

  5. How to Check if SharePoint Group Exists Using NINTEX Workflow

  6. How to Create User Defined Action For NINTEX Workflows in SharePoint

  7. How to Add a Group in SharePoint Site Using NINTEX Workflow

  8. How to Remove Group From SharePoint Site Using NINTEX Workflow

  9. How to Set Item Level Permission Using NINTEX Workflow in SharePoint

  10. How to Create Item in Another Site Using NINTEX Workflow in SharePoint

  11. How to Get All the Users From a Specific SharePoint Group Using NINTEX Workflow 

  12. How to Convert Word Document to PDF Using NINTEX Workflow in SharePoint

Recent Posts

See All