Retrieve a user's Display name from their login

Document created by Emily Billing Employee on May 28, 2014Last modified by Emily Billing Employee on Feb 7, 2016
Version 3Show Document
  • View in full screen mode

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.

2 people found this helpful

Attachments

    Outcomes