Infopath 2010 : How to get a user’s name or account to appear in the form
If you need to create an InfoPath form with the user’s name or account appear in a form, InfoPath has a way to connect to SharePoint’s UserProfile service. This article will explain the process to set up a proper data connection in the InfoPath form and then display user names, accounts, emails etc.
If you want to return the Account ID value back to the form, InfoPath has a build-in functions to help retrieve that.
Add a field to you form, right click Textbox properties, go to Data tab, then click the Insert formula button in
You can select the username function to return the name of the person filling out the form.
This will likely return first initial and last name.
By adding a concatenation formula to the username you can modify it so it appears as an email.
Test the different functions in order to achieve your desired results.
Creating the Data Connection
The other way to get user’s information is through the UserProfile Services built in SharePoint.
In your InfoPath form, select the Data tab and then click ‘Data Connections’ button.
In the Data Connections dialog window click ‘Add’ which displays the Data Connection wizard.
Be sure the radio button ‘Receive data’ is selected and then click Next. Now the option to choose
is “Soap Web Service.” You need to specify the User Profile Service URL. The format of the URL is
Note: Be sure to call the User Profile Service from the same location as your Infopath form. So if your form
is located under mysite2, the make sure the URL points to that site.
Click next until you see the window below and then choose “GetUserProfileByName”
Click next till you get to the last window. Leave the checkbox selected for “Automatically retrieve data
when the form is open.” This way, the field will automatically load users name every time the form is
opened in a browser window. You should now have two data connections set up.
Retrieving the Data from User Profile Service
This section is where we pull it altogether. Back in the InfoPath main menu, select Data tab again and then
click “Form Load” button. The Rules panel will open. You need to add a rule to when the form load the query
the User Profile service. Select “New”, “Action” and then “Add” to run the action. The first action needed is
to Query for Data. Change the Data Connection to GetUserProfileByName. Click OK.
Now add a second Action. This time it will be to “Set a field’s value.” This is where all the magic happens. By calling the service and using a filter, you can display a user’s full name in a form field.
In the Rule’s Details dialog, select which field you want to display the name. In the Value section,
Select the Function button.
Click “Insert Field or Group” button and then “Show Advanced view” link on the bottom.
Change the Fields dropdown to “GetUserProfileByName” and then expand the tree view until you see “Value.”
Select the “Filter Data…” button and click “Add.” Here is where you need to specify filter conditions.
Change the first drop down to “Select a field or group” and then choose “Name” from the tree view.
Change middle dropdown to “Is equal to” and the select third dropdown to “Type in text” and add
the following text “PreferredName.” Click OK to close all your windows.
Before you publish to SharePoint, PREVIEW your form in InfoPath. Select Home tab and then Preview button. You should be able to see full name of the user.