Skip to main content
Nintex Community Menu Bar

This seems to be a common ask, and this is by no means the only way to do this! This is a simple approach using out-of-the-box functionality and can be setup in a few minutes in a site workflow or a list workflow.

 

The "ask":

Return all users from a SharePoint User Group in First Name Last Name format.

 

Setup and Overview:

First step is to get the User Group name that we need to interrogate. Once we have that, we can make a web service call and get a collection of all logins, loop through them and build a list of all users. Done.

 

Here are the variables that I will be using:

190115_pastedImage_0.png

**Note that I am doing this as a SITE WORKFLOW and have my varGroupName required and on my start form.

If you want to make this in a list workflow, you will need to alter that piece and feed it in a different way.

 

The workflow:

190117_pastedImage_2.png

1. Get Group Name - This is simple enough, just ask for the user to type it in. Be careful though; it will try to find exactly what you put in, so if it is misspelled, you are not going to get results. We do this in the workflow start form and then feed it into the web service call.

 

2. Call web service - Here we want to specify the web service (GetUserCollectionFromGroup) and feed it our group name variable. Be sure to test this with an actual group name to ensure you will get results. It will also be helpful when testing and setting up the next step as well. Also, if you want to alter this, it helps to know what XML you are getting back. Then we need to store the resulting XML in a variable and we are set!

190118_pastedImage_3.png

3. Query XML - Now that we have our results, we can query the XML and pull out all the users logins. If you grabbed the actual XML from the previous step, you can paste it in the XPath Builder to get the exact XPath you will need. Again, testing with actual data is better so you can see what is going on before you publish and try it. Once setup, simply store the results into our collection variable.

190119_pastedImage_4.png

4. Loop for each user in the collection -

Here is where the names get pulled out and first and last names are smashed together.

In our For each action, we want to look at the collUsers and store each one (one at a time) into varUserLogin.

190122_pastedImage_7.png

Using Set variable actions, set varUserFirstName and varUserLastName by looking up first name and last name from User Profile details based on varUserLogin, like so:

190120_pastedImage_5.png190121_pastedImage_6.png

At this point you have varUserFirstName and varUserLastName and can do whatever you need to with it. Perhaps you need to use it in an email, or write to a list. For this example, I am going to create a full list of all users in the group. I do this by using a Build string action and adding in varUserFirstName and varUserLastName along with the varGroupUsers to continue building on top of itself.

190123_pastedImage_16.png

 

5. Email list of users - Now that I have a full list of users, I can email myself the results:

190124_pastedImage_18.png

 

190125_pastedImage_19.png

 

Again, this is not "the definitive" way to accomplishing this, simply how I did it. I would be interested to know how other accomplished something similar to this, or if someone created a UDA to plug into workflows would be even better. If I have some time, I may do that.

 

I added the .nwf file here in case anyone wants to grab it and use it. Do note that it is a SITE WORKFLOW, but you can always create the site workflow and then save it as a snippet.

 

Let me know your thoughts and comments! 

 

Until next time!

Great Jesse,

Thanks for explaining the procedure in detail with example and attached workflow.  It is really informative.  I will try this in my next workflow which needs use of usergroups.

Where shall I the list of web services like /usergroup.asmx and XPath.

Thanks a lot.

Cheers:)

Sunil


Hello Jesse,

Exported workflow given by you and published.  On running it give error as

"Failed to invoke web service. Error returned from server: <soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."

We have user data stored at another domain.

Sunil


Yeah, the web service has to run in the same domain that you call it from. The web service will not work when going cross domain. Not sure if it would work, but if you setup the lookup part in the other domain and call it, then pass back the data, but I think you'd run into the same issues.


Hi ‌, I was able to use your solution, Thanks for the details. It is working fine when looping through the SharePoint group. Do you know what do I need to do to make this work for an AD group instead? I've tested it by just changing the name and providing account name of AD group that's on sharepoint but it's giving me the same error as ‌.


I would generally use Powershell and go after it that way, but if you are looking to use Nintex and automate it, take a look at the Query LDAP action.

Within the action you can provide the LDAP path along with your query you want to run. 


Reply