March 11, 2021

How to get Current User information in InfoPath form using SOAP Web service with Share Point Online


Introduction

We recently migrated InfoPath Forms from SharePoint On-Premises to SharePoint Online for a Postal and Parcel company based out of Melbourne, Victoria, Australia. In this migration, we updated all the data connections of the InfoPath Forms for compatibility with SharePoint Online. So, in this blog, we will explore one of the data connections and will learn how to get Current User Information in InfoPath form using the SOAP web service with SharePoint Online (Office 365).
 

Steps to get the current user details.

 Step 1: Open your InfoPath form in InfoPath Designer. Open “Data Connection”, then click on the "Add" button.


Step 2: It will open a new "Data Connection Wizard", select "Create a new connection to:" and “Receive data” and Click on the “Next” button.

            


Step 3: Select “SOAP Web Service” and click on the “Next” button.

            


Step 4: Provide your URL and click on the “Next” button.

               Replace your URL with this ({yoursharepointsite}/_vti_bin/UserProfileService.asmx).

        


Step 5:
In the next window, select “GetUserProfileByName” from the operation list and click on the “Next” button.


Step 6: Click on the “Next” button.

                          


Step 7: Click on the “Next” button.


Step 8: Provide your connection name, select “Automatically retrieve data when form is opened”  and click on the “Finish” button. “Connection Wizard” will be closed automatically.


Step 9: In the “Data Connection” window new connection will be displayed, close the connection window.


Step 10: Add a new "Text Field" in the Fields panel. For adding text field, right-click on my fields and select the "Add" option.


Step 11: New popup will be opened, provide the name and click on the "OK" button. Here we have provided the "CurrentUser" Name to the text field.




Step 12: New field will be added in the fields panel, now right-click on the newly added field and select textbox.


Step 13: New textbox will be added to the form.




Step 14Right-click on the textbox and select “Text Box Properties”.


Step 15: New dialog will be opened, click on the "formula" button.



Step 16: Once you click on the formula button "Insert Formula" popup will get opened, then select "Insert Field or Group" option.



Step 17:  "Select Field or Group" popup will be opened, then explore Fields dropdown and select        "GetUserProfileByName" connection.




Step 18: Once you select "GetUserProfileByName" all fields will be displayed of GetUserProfileByName connections. Expand data Fields and select the last "Value" field and click on the "Filter Data" button.



Step 19: "Filter Data" dialog box opens, then click on the "Add" button.



Step 20: Now “Specify Filter Conditions” dialog opens, from that expand the left drop-down and select the “Select a Field or Group” option.




Step 21: In the new dialog select "Name" filed of the "Property Data" and click on "OK".




Step 22: Once you Click on the "OK", dialog box is closed and now expand the right dropdown and select Type text”.




Step 23: Add “PreferredName” in the textbox to display current user Display Name and click on the "OK" button.



Step 24: Now click "OK" to all open dialog box and in the "Insert Formula" dialog box you will see the below formula, then click on the "OK" button.



Step 25: Now you will see the below formula in the Text Box Properties dialog. Click on the "OK" button.

Final Output

Save the form and open it in preview mode. When the form will be loaded, the Display Name will be set in the "CurrentUser" textbox as shown below.

Conclusion

This is how we can get current user information details in InfoPath form using SOAP web service with SharePoint Online (Office 365).

If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment