cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Retrieve a user's Display name from their login

Relevant to both Nintex Workflow 2013 and Nintex Workflow 2010.

This article describes two methods of looking up a user’s display name for use in a workflow.

  1. The first method will query Active Directory using the Query LDAP action.
  2. The second method calls a SharePoint Web service using the Call web service action.

Creating the SharePoint list

Create a SharePoint list, and add a Person/Group column type. Create an item adding a valid user account to the domain/username column.

new_item.png

Note: SharePoint will display the user’s display name in the list view; however, when the workflow reads this value, it retrieves this value as domain\login for the user.

Method 1: Query Active Directory using the Query LDAP action

Create the Workflow

Open the Nintex Workflow designer, then add a Regular expression and Query LDA to the design canvas.

regular.png

Create the Workflow Variables

Click on the Workflow Settings drop down menu in the Ribbon, and select Variables. Create the following four variables:

  1. Name: xmlResult, Type: Single line of text
  2. Name: displayName, Type: Single line of text
  3. Name: displayName2, Type: Single line of text
  4. Name: justUserName, Type: Single line of text

workflow_variables.png

Configure the Regular Expression action


The Query LDAP action needs to be able to utilize the information within the Person/Group field, we must first remove the DOMAIN\ component from the selected user, with the Regular Expression action.

  1. Double-click on the Regular Expression action to open the configuration dialog.
  2. In the Pattern text box, type "DOMAIN\\".
    Note: This will replace DOMAIN with the actual domain name. The "\" character has a special meaning in regular expressions, two backslash characters are used which tells the Regular Expression to threat this as a single backslash character.
  3. In the Input Text field, click on Insert Reference. Select domain/username from the Item Properties field.
  4. In the Store result in drop down, select justUserName.

regular.png

The username should now be in a format recognized by LDAP queries.

Configure the Query LDAP action

This action will retrieve and store the required information within the displayName workflow variable.

  1. Double-click on the Query LDAP action to open the configuration dialog.
  2. In the LDAP path field, enter the path which will point to the Active Directory for your environment. Enter a Username and Password which is a valid Active Directory account which has permissions of at least Read access. 
  3. In the Query field, type "(&(objectClass=user)(samaccountname=", and then insert the reference "justUserName" from the Workflow Variable tab.
  4. In the Property to retrieve field, type "displayName" and click Add. Then in the new drop down, select the variable displayName.

query_ldap.png


Method 2: Call a SharePoint web service

Now we're going to demonstrate an alternative method of retrieving the display name by querying a SharePoint Web service using a Call web Service action.


On the same workflow, add a Call Web service, Query XML, and Send notification action to the design canvas.

regular.png

Configure the Call Web Service action

  1. Double click on the Call Web Service action to open the configuration dialog.
  2. In the URL field, select the Insert Reference icon and add the Web URL reference. Then type "/_vti_bin/UserGroup.asmx" to complete the path to the Web service.
  3. Configure the Username and Password fields with an account that has permissions to call the SharePoint Web service.
  4. Click the Refresh button. Now we can select the appropriate Web method from the drop-down list. Click on GetUserInfo (for more information on this web service, http://msdn.microsoft.com/en-us/library/ms774637.aspx.
  5. In the userLoginName (string) field, click on the Insert Reference icon. In the Item Properties tab, select domain/username.
  6. In the Store result in field, select xmlResult, and click Save.

call_web.png

The web service will return a fragment of XML.

Configure the Query XML action

This action will parse the XML returned from the web service to extract the display name value needed to be used in other workflow actions. The Xpath query will extract the Name value and store the result in the displayName2 workflow variable.

  1. Double click on the Call Web Service action to open the configuration dialog.
  2. In the XML source, select XML.
  3. In the XML textbox, click on Insert Reference, and select xmlResult from the Workflow Variable tab.
  4. In the Process using textbox, type "//@Name", and then select displayName2 in the Store result in field.

query_xml.png

The displayName2 workflow variable should now contain the user's display name retrieved from SharePoint.

Test the workflow

Configure the Send Notification action

  1. Double click on the Send Notification action. In the To field, click on the Lookup icon, and select Initiator form the Lookup section.
  2. In the Subject, type "Display name tutorial".
  3. In the Email text box,
    1. Type, "This is the user's login -" and use the Insert Reference icon to include domain/username.
    2. Type, "This is the display name retrieved using an LDAP query" and use the Insert Reference icon to include displayName.
    3. Type, "This is the display name retrieved using the UserGroup Web Service" and use the Insert Reference icon to include displayName2.

send.png

Note: The other option is to use the Log in History List action to log the above values/ workflow variables instead of sending an email notification.

Publish and Run the workflow

Run the workflow on your SharePoint list item.

Labels: (1)
Reply
15 Replies
esthomason
Nintex Newbie

Re: Retrieve a user's Display name from their login

In the Call Web Service action described above you state, "

  1. In the userLoginName (string) field, click on the Insert Reference icon. In the Item Properties tab, selectdomain/username."

What might cause domain/username to be unavailable as an option to select in Item Properties? The authentication was successful and returned the list of web methods.

0 Kudos
Reply
DrewA
Nintex Newbie

Re: Retrieve a user's Display name from their login

I do understand I am new to Nintex workflow and still getting my 'sea legs' here. However, after reviewing above and similar solutions in various question threads, I must say that, this is a very complex task to achieve a very common outcome: having the display names from a people/group field appear in an email body of a send notification action. My reference, is, of course, how it was achieved in SharePoint Designer. I know, I know: Nintex workflow isn't SPD. It is something much better and much more extensive. But, to have to jump through all these hoops in Nintex, as above, to achieve the same outcome that SPD achieves by simply checking the correct output when adding a people/group field to an email notification is astonishing given how wonderfully Nintex behaves in dominating other aspects of SPD workflow.

Can the ability to set the output type via a simple drop-down selection as in SPD (i.e. select 'display name' 'display names, semi-colon delimited,' etc) in a people/group field when added to the email body in the send notification action be looked into for a future release (I am on Version: 3.0.8.0)?

0 Kudos
Reply
Not applicable

Re: Retrieve a user's Display name from their login

Hi Drew, thanks for taking the time to explain your experience and the difficulties you are having with this. I'd recommend adding your idea and feedback to Nintex's feedback site 1 - Nintex Workflow for SharePoint: Hot (324 ideas) – Customer Feedback for Nintex where others can comment and vote, and our product team uses this space as prioritization for features as well.

0 Kudos
Reply
DrewA
Nintex Newbie

Re: Retrieve a user's Display name from their login

I could not get the LDAP method to work. It appeared I could not remove the regular expression in our Login ID, which is in the format of "i:0#.w|us\1110mu". In reviewing the resulting variable in the history log, the special character "|" (pipe) could not be removed and always yielded a variable in the format of "|1110mu" This appeared to be the point of failure. Is there a way to force recognition of this special character similar to getting the "\" character recognized as such by entering "\\" for it? I tried entering "||" and that didn't work.

The web service worked but only for a single user entered into my people/group field.

When two (or more?) were entered it failed with the error message:

Failed to invoke web service. Error returned from server:

<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soapSmiley Frustratederver</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

Your example above only uses one individual. Can you demonstrate how the web service method would work for two or more IDs?

0 Kudos
Reply
Not applicable

Re: Retrieve a user's Display name from their login

Hey Drew, could you please post this question in the Learn More​ space? This is past my knowledge, and that way it'll be more visible to the community, so they can chime in!

0 Kudos
Reply
DrewA
Nintex Newbie

Re: Retrieve a user's Display name from their login

This just happened to me, too. While previously, as noted in my comments (below on this page), it worked, I no longer see the "domain/username" selection the "item properties" tab. ?? I am a sites collection admin, too, and am using my current credentials.

UPDATE: I was not paying attention to the entire exercise--just concentrating on the directions for each method. The 'domain/username' is not a system field...it's what we were asked to create at the top of this page! You can substitute ANY people/group field you have in a list, including Created By and Modified By, which is what I needed.

0 Kudos
Reply
DrewA
Nintex Newbie

Re: Retrieve a user's Display name from their login

Update.

First, I discovered how the "\" works here. Placing it in front of the pipe such as in i:0#.w\|us\\1110mu removed it and the back slash.

This did yield the users ID which I then stored in the variable used to query LDAP.

Once this is done, save the workflow as a snippet. I then brought it into a workflow where this query has to be made for as many people listed in a people/group field. You apply the collection variable and its related actions (i.e. 'for each') for every item in the collection variable.

0 Kudos
Reply
suzyshush
Nintex Newbie

Re: Retrieve a user's Display name from their login

In my Nintex 2010 sandbox site, I have a simple test workflow on a list that has a people field that only allows a single person chosen.  the workflow uses multiple "Set variable" actions to leverage the user profile service in different ways.  The output from the workflow can show anything that it finds the person's user profile.  Here's a sample output from my test:

12/21/2015 11:56 AM Workflow Comment Distinguished name is CN=Jason Smith etc. etc. etc.

12/21/2015 11:56 AM Workflow Comment Name is Smith, Jason (US - State Name) 

12/21/2015 11:56 AM Workflow Comment User Name is jsmith 

12/21/2015 11:56 AM Workflow Comment First Name is Jason 

12/21/2015 11:56 AM Workflow Comment Last Name is Smith

12/21/2015 11:56 AM Workflow Comment Account Name is "ourdomain\jsmith"

12/21/2015 11:56 AM Workflow Comment Job Title is  

12/21/2015 11:56 AM Workflow Comment Department is "Our Department Name"

The Set variable actions will look something like this:

Set Variable.JPG


If we had a column that allowed multiple approvers and set a workflow variable to that column, then you'd need to use one of the mothods above to work with the output because it would look kind of like this:  511;#Smith, Jason (Atlanta);#816;#King, Mary (Atlanta)

For example, you can make a web service call to _vti_bin/usergroup.asmx "GetUserCollectionFromGroup" method that uses a SharePoint group name as input, and outputs to a multiple line of text variable.  Then you would query the XML using the multiple line of text variable as input for the names that are contained in that SharePoint group.

0 Kudos
Reply
Highlighted
wlemons
Nintex Newbie

Re: Retrieve a user's Display name from their login

Hello,

How would I use this ldap query above to get a user's group memberships?

Thanks,

William

0 Kudos
Reply