I need to automatically populate user’s information on an InfoPath form.  This is not as simple when the Web Application is configured using Claims Based Authentication as in SharePoint 2010 or 2013.  I blogged this topic before on a different forum, but I thought I did not include enough explanation on how to resolve the issue.  So, this time I will include step-by-step instructions.

Let’s get started.

1. Create a SharePoint List, I called mine ‘Resources’, with the following columns:

  • Account ID          Text
  • First Name          Text
  • Last Name           Text
  • Full Name            Text
  • E-mail                  Text
  • Manager              Text
  • strCurrentUser   Text (This is my “placeholder” field.)

2. Navigate back to the Resources list, click the List tab, and click Customize Form from the Ribbon.

The following screenshot shows the OOTB List Form.  I’ll modify this a little.

StandardListForm

The following screenshot shows minor modifications made to the form.

StandardListForm-Modified

3. From InfoPath, click the DATA tab, then click From SOAP Web Service under From Web Service

FromSOAPWebService

4. In Data Connection Wizard, type:

http://<Your Web App>/_vti_bin/UserProfileService.asmx, then click Next

5. Select GetUserProfileByName from the operation list, then click Next

GetUserProfileByName

6. In the Parameters screen, click Next

Parameters

7. Click Next on the next screen

StoreCopyInFormTemplate

8. Use the default GetUserProfileByName under Enter a name for this data connection

9. Check the Automatically retrieve data when form is opened, then click Finish

SaveDataConnection2

10. In InfoPath Design, under Fields, select Show advanced view

InfoPathAdvancedFields

11. Click DATA tab, click Form Load from the Ribbon to display Rules window

InfoPathFormLoad

12. In Rules window, click New and select Action

13. Under Details for, type: Get Current User Information

14. Under Condition, click None – Rule runs when form is opened. This will open the Condition Window.

GetCurrentUserInformationRule

15. Change myFields to Select a field or group… (This will open the Select a Field or Group window.)

16. In the Select a Field or Group window, change the Data source to GetUserProfileByName (Secondary)

17. Expand queryFields until AccountName appears, select AccountName, and click OK

SelectAccountName

18. In the Condition window, change is equal to to is blank, click OK

AccountNameIsBlank

I now need to make the Web service call to the User Profile Service to get user information.

19. In the Rules window, under Run these actions, click Add, and select Query for data

20. Verify that GetUserProfileByName is selected, click OK

QueryForData

21. In the Rules window, under Run these actions, click Add, and select Set a field’s value

22. In the Rule Details window, in the Field section, select the FieldSelectorIcon   icon

23. In the Select a Field or Group window, verify that Main is selected

24. Expand the dataFields until you see Last Name

25. Select Last Name and click OK

SelectLastName

26. In the Rule Details window, in the Value section, select the FormulaIcon  icon

27. In the Insert Formula window, click Insert Field or Group… (This will open the Select a Field or Group window)

28. In the Select a Field or Group window, change the Fields value from Main to GetUserProfileByName (Secondary)

29. Expand the dataFields until you see Value

30. Select Value, and click Filter Data…

SelectValueAndFilterData

31. In the Filter Data window, click Add (This will bring up the Specify Filter Conditions window.)

32. In the Specify Filter Conditions window, change Value to Select a Field or Group…

SelectCondition

33. In the Select a Field or Group window, select Name, and click OK

SelectName

34. In the Specify Filter Conditions window, change the last drop down to Type text…

35. Type LastName, and click OK (This will return you back to the Filter Data window

FilterDataLastName

36. The Filter Data window, now has the LastName information, click OK

FilterDataLastName2

37. Click OK to close Select a Field or Group window

38. Click OK to close Insert Formula window

39. The Rule Details window now has LastName in its value field, click OK

RuleDetailsLastName

40. Let’s test the configuration we’ve done so far. Preview the form.

FormPreview3

41. So far so good. Close the form preview window.

42. Publish the form to the SharePoint list (Resources)

43. Open the SharePoint list the browser

You should now be taken back to the SharePoint list in your browser.

44. Click new item

45. A Warning window appears with a message An error occurred querying a data source. Log ID:5566

Error5566

46. After clicking OK the form is loaded without user information.

This error (5566) is expected when making a Web service call in SharePoint configured with Claims Based Authentication.  We will now leverage the “placeholder” field (strCurrentUser) we created earlier.

Go to part 2 of this series

Auto Populate User Information in InfoPath with Claims Based Authentication – Part 2 of 3

Auto Populate User Information in InfoPath with Claims Based Authentication – Part 3 of 3

Learn more about Centric’s Portals and Collaboration Practice

Advertisements