Check user and add user to SharePoint group

A customer requested the use of target audiences on the front page of a SharePoint site. The audiences would be based on a SharePoint group. The problem was that the members of this group would be dynamic.

So we needed to create a workflow that would check if the user was a member of the group and add the user if they weren't. There isn’t a standard action in Nintex called something like "Check if user is in group?", so we need to use a web service to check this.

Create workflow

Add the following actions to the workflow:

  • Call web service
  • Query XML
  • Collection operation
  • Set a condition
  • Call web service


The following variables where so kind to help us with the creation of this workflow:

  • XMLUserGroups (Single line of text)
  • ColUserGroups (Collection)
  • YNUserMember (Yes/No)

Call web service

Double click the Call webs service action to configure it.

  1. Click on the Insert Reference button (the address book) at the field url.
  2. Select from the Tab Comment the reference Web URL.
  3. Add the text /_vti_bin/usergroup.asmx.
  4. Click on OK.

 Add User to Group

Enter a username and password, as always: Using Workflows Constants for usernames and password is the preferred option!

  1. Click on Refresh by Web Method to get all Methods.
  2. Select GetGroupCollectionFromUser.
  3. The field userLoginName needs to contain a username, we are entering the Insert Reference Created By.
  4. And now we store the outcome in a text variable, select XMLUserGroups in the field Store result in.
  5. Save the action.

Query XML

As you have guested, we receive a response from the web service in a XML message. With the Query XML action we strip all unwanted data from the response so we only keep the groups.

Enter the workflow variable XMLUserGroups in the XML field.

As XPath query enter the following:

Store the result in collection variable, the ColUserGroups collection.

Add User to Group

Collection operation

As all groups are stored in a collection we can now use the Collection operation action to check if our SharePoint group is in that collection. And with that also that the user is in that group.

  1. Target collection is the collection where the XML result was stored, this is the ColUserGroups collection.
  2. Select the Exists option.
  3. Value, here you need to add the group that needs to be checked. In our example we check the very fictive group ManagerWebpart.
  4. The result is true or false, store this result in YNUserMember

Add User to Group

Set a condition

The Set a condition action is used to determine if the YNUserMember variable is yes.

Condition, from the pull down select If any value equals value.

Set the Where part as followed:
Workflow Data YNUserMember equals Value Yes.

Add User to Group

Call web service

Add a Call web service to the left side of the Set a condition action.

The URL, Username and Password are identical than the previous web service action.

Select AddUserToGroup by the Web Method.

Add the group by the field groupName and Insert Reference Created By for the field userLoginName.

Add User to Group

Save and publish the workflow.

If you liked this article be sure to have a look at Nintex Workflow User's Guide for more tips, tricks and hands-on assignments.

1 comment

  • Parveen

    Hi ,
    I followed above article but I don't see my user added in the SharePoint group.

    What can be the issue?

    Please help.

    Parveen Thursday, 28 January 2016 13:39 Comment Link

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.


BleiCon can provide standard or customized Nintex trainings from end-user to administrators.

Discover what Nintex training fits your organisation


Meulenspie 21
4847 TK Teteringen


BleiCon is Microsoft Certified Partner


Bleicon is Nintex Workflow Pro certified

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.