(SharePoint Enterprise Edition ONLY)

By using the SOAP web service there are many user properties that we can retrieve and automatically populate onto fields in the SharePoint list form.

There is a built in InfoPath field property called userName() which can be used to return the user id/ account id. To get other details such as display name, email id, manager, phone number, etc., we can use the web service “UserProfileService.asmx”

I am going to show how to retrieve the current username but in a user friendly format to a filed on your form.

First ensure you have created a text field in your list to hold the username property then select the customize form button on the ribbon as shown below (this option is only available if you are using SharePoint Enterprise edition and have enterprise licenses)

blog image

Create a New Data Connection

blog image

then Soap Web Service Option and enter the url for your web service in this format:

http://yourhostsitename/yoursite/_vti_bin/UserProfileService.asmx

blog imageblog image

Step 2 - Select the method GetUserProfileByName.

blog image

Click next then next and finish the wizard with the checkbox for “Automatically retrieve data when form is opened” checked.

Your new data connection is now created.

Set the Your UserName Field to Use the UserNamepropoerty

In your form, go to the properties of your name textbox. In the ‘Default Value’ part, click the ‘fx‘ button next to the ‘Value’ field.

blog image

Click Insert Field or Group

blog image

Select the advanced view at the bottom of the screen then ensure you are on the GetUserProfilebyName field in the drop down at the top. Select GetUserProfileByName data source.

blog image

 

blog image

Keep expanding the groups under the ‘dataFields‘ group, and choose the ‘value‘ field.

blog image

Select “Filter Data” button after selecting value, and click “Add“. Filter screen appears with three dropdowns. In the first dropdown, select “Select a field or group…” and select ‘Name‘ field under the ‘PropertyData’ group.

blog image

Let the second drop down be unchanged (is equal to).

In the third drop down, select “Type Text…” and write “PreferredName".

blog image

This third drop down will decide what property is to appear in your textbox. Alternatively to return the users emailaddress , repeat all above steps with this last dropdown being set to “WorkEmail“. For account id, repeat all above steps with this last dropdown being set to “AccountName“.

Close all open dialog boxes by clicking ok.

Preview to see the output.

Below is a list of other properties that can be returned by the userprofileservice:

AccountName
FirstName
LastName
PreferredName
WorkPhone
Office
Department
Title
Manager
AboutMe
PictureURL
UserName
Assistant
WorkEmail
CellPhone
Fax
HomePhone

If you want to know learn more about SharePoint or how it can be used to help your business book onto one of our SharePoint courses.