InfoPath DisplayName is Empty When Using UserName()

You created an InfoPath form, then added a text box to show the current users display name. Safe to assume you populated the text box using a rule and a set field value action. In the set field action, your Xpath might look like this:

xdXDocument:GetDOM(“My Data Connection”)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Employee_x0020_Name_x0020_2/pc:Person/pc:DisplayName[../../../d:Title = concat(“DOMAIN\”, xdUser:get-UserName())]

In my case, when the user accessed userName(), it was returning a value other than what is in Active Directory. UserName() would return Jdoe but Active Directory had the user listed as jdoe. This caused the text box to be empty in my form.

Look at the local user account on their machine.

http://www.thewindowsclub.com/user-account-name-change

Update users display name in SharePoint

The script below will allow you to change a users display name in SharePoint.


# add SharePoint snap-in if needed

 	$ntName = "domain\XXX"
	$displayName = "New Name"
 	$webApp = "http://webapp.sharepointed.com/"
	$user = Get-SPUser -web $webApp -Identity $ntName
	
	Get-SPWebApplication $webApp | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | ForEach-Object {
		Set-SPUser -Identity $user -DisplayName $displayName -Web $_.URL
	}