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.
The following screenshot shows minor modifications made to the form.
3. From InfoPath, click the DATA tab, then click From SOAP Web Service under From Web Service
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
6. In the Parameters screen, click Next
7. Click Next on the next screen
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
10. In InfoPath Design, under Fields, select Show advanced view
11. Click DATA tab, click Form Load from the Ribbon to display Rules window
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.
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
18. In the Condition window, change is equal to to is blank, click OK
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
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 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
26. In the Rule Details window, in the Value section, select the 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…
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…
33. In the Select a Field or Group window, select Name, and click OK
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
36. The Filter Data window, now has the LastName information, click OK
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
40. Let’s test the configuration we’ve done so far. Preview the form.
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
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
I’ve followed these steps with a succesful result as expected.
However, whe doing this in an environment that uses ADFS and SAML-claims I cannot seem to get pass the 5566 error.
Is it possible to implement this solution together with a SAML-claims authentication method?
Thank you , very helpful. it worked with me
I followed these steps as describet. But i recieve at the end an “access denied” on secure store. I dont know why. Even the Service User is a member of the target application. Please need help!
Thx
Pingback: Get Current UserName in Infopath always returns the secure store service credential name | DL-UAT
Pingback: Auto Populate User Information in InfoPath with Claims Based Authentication in SharePoint | Rob Devereaux
Pingback: InfoPath in SharePoint 2013 – Configuration to use it – guidesharepoint
Reblogged this on Prasad's Blog and commented:
Get data from from web service in infoPath Part 1
Thaaaaaaaaaaaaaaanks for great post…
Its really useful
Pingback: Infopath Form that switches views based on the current user – Becky's SharePoint Journey