My current project is using SharePoint 2010 and InfoPath 2010 to collect specific business related data. The initial design had three different text boxes to collect a proper name, username and email. There is nothing wrong with this approach, but this specific form had 15 individuals that we needed to collect data for. The would be a lot of data entry. Why couldn’t we just enter a user name and bring back all of this data?

Performing some quick internet searches, there are many great articles that accomplish the desired results using a Web service call to GetUserProfileByName. These articles showed step-by-step instructions on how to accomplish the desired results, but they only demonstrated how to use this technique for the current user. Even though I needed the information for the current user, I also had a business requirement to retrieve the information for other individuals in the company based on their username. Hopefully the following article will help you use the Web service approach for any person listed within your People Picker (or text box).

Steps I used:
1. Add a new data connection
IPUserProfile_Step1

2. Select “Receive data” and click Next
IPUserProfile_Step2

3. Select “SOAP Web service” and click Next
IPUserProfile_Step3

4. Enter your site collection url and add “/_vti_bin/UserProfileService.asmx?WSDL” and click Next
IPUserProfile_Step4

5. Select “GetUserProfileByName” and click Next
IPUserProfile_Step5

6. Leave parameter value blank, click Next
IPUserProfile_Step6

7. Uncheck (if checked) “Store a copy of the data in the form template” and click Next
IPUserProfile_Step7

8. Uncheck (if checked) “Automatically retrieve data when form is open,” name your data source, click Finish.
IPUserProfile_Step8

9. In the InfoPath form, add an “action” rule to an event (for demonstration purposes I am using a button).
IPUserProfile_Step9

10. Click Add, select Set a field’s value. Fill in the Field and Value text boxes.
IPUserProfile_Step10.1IPUserProfile_Step10.2
IPUserProfile_Step10.3IPUserProfile_Step10.4

11. In the InfoPath form, add another “action” rule to the same control. This time select “Query for data” and select the Web services created in step 8.
IPUserProfile_Step11

To retrieve values from the Web service, perform the following (PreferredName is shown as an example).

1. Determine what field you would like to populate (PreferredName). Click the fx button

UserProperties1

2. Click “Insert Field or Group…” button

UserProperties2

3. Switch to the Web service created earlier and select the “Value” property, and click the Filter Data button

UserProperties3

4. Click Add button

UserProperties4

5. Select “Select a field or group”

UserProperties5

6. Switch to the Web service created earlier and select the “Name” property

UserProperties6

7. Select “Type text…” and enter PreferredName

UserProperties7
UserProperties8

The Web service GetUserProfileByName holds many properties that might be useful:
UserProfile_GUID, AccountName, FirstName, LastName, PreferredName, WorkPhone, Office, Department, Title, Manager, AboutMe, PersonalSpace, PictureURL, UserName, QuickLinks, WebSite, Assistant, WorkEmail, CellPhone, Fax, HomePhone, PublicSiteRedirect, SPS-Dotted-line, SPS-Peers, SPS-Responsibility, SPS-Skills, SPS-PastProjects, SPS-Interests, SPS-School, SPS-SipAddress, SPS-Birthday, SPS-MySiteUpgrade, SPS-DontSuggestList, SPS-ProxyAddresses, SPS-HireDate, SPS-LastColleagueAdded, SPS-OWAUrl, SPS-ResourceAccountName, SPS-MasterAccountName

Like this post? Share it!