How To: Get User IDs from SharePoint Group with Nintex Workflow

In a recent conversation with a client, who uses Nintex Workflow 2010, I was asked if it is possible to send personalised emails to individual users in a SharePoint group. In Nintex’ Send Email action you can choose to send an email to the whole group or an email to each member of the group. This however doesn’t meet the requirement of sending truly personalised emails to individuals, since the email body will be the same for all of the recipients.

So what can you do to get the members of a group and then send each of them an email? Easy enough since SharePoint provides a web method as part of the UserGroup.asmx web service. Then we package that up in a UDA and everyone can use it without the hassle of implementing it over and over again. Note that the logic of the UDA can also be implemented in Nintex Workflow 2007, it just can’t be wrapped into a UDA.

How does it work?
The workflow within the UDA consists of 2 parts

First we call the UserGroup (http://[SITEURL]/_vti_bin/usergroup.asmx) web service and use its GetUserCollectionFromGroup web method, which will bring back an XML with information about every user in the specified SharePoint group.

The XML looks something like this:


Next we use the “Query XML” action to extract the users’ ID and put them in a collection. The query will look like that:


Note the “xml” node at the start. This is because I selected “Force top level XML node” in the “Call web service” action. You can find that option under “Store result in” when you expand the “Result processing” option.

That is all we do. Of course you can query any of the other properties too. The returned properties for each user are:

How do I use the UDA?
Drop the UDA into the right spot within your workflow logic. The UDA requires only one input parameter:

In return the UDA will spit out a collection of all the IDs of all the users in the group:

In the event of an error within the UDA (connection issues, group already exists, etc.) there are 2 additional output parameters:

Using the output parameters will help you to handle the exception appropriately within your workflow.

The web service in the UDA uses a workflow constant (Site Collection Level) called “SharePoint Web Service Account” of the type credential. You will have to create this constant before you can use the UDA as it currently stands. The account will have to be able to read web services across the site collection, so read only access to all sites for this account will be fine.

Alternatively you can modify the UDA in a way that the credentials are passed to the UDA as part of the input parameters.

What’s next? After the UDA you simply drop in a “For each” action and a “Send notification” action. That is it. The workflow should now have a section as shown below.

Now we need to configure the actions.

So what does that have to do with personalised notifications? Well, within the “For each” action, just before the “Send notification” action you can use the variable “tempUserID” to get personlised information about the current user. For example you could query the user profile to get his/her name, address, phone number, etc. BUT, this I will leave up to you, but I think you can see now what my client was trying to do J

Get SharePoint Group Members – UDA and NWF files

, , , , , ,

7 thoughts on “How To: Get User IDs from SharePoint Group with Nintex Workflow

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Visit Us On TwitterVisit Us On Linkedin