How to set current user details in an InfoPath form



userName() method of Info Path form returns 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”
Lets say we want to get the display name, email and accound id for the currently logged in user.
form
Below steps are used to configure the User Profile Service and get details out of it.
Step 1 – Add a data connection, select Receive Data and Soap Web Service Option and enter the url for web service in this format “http://sever/sites/site/_vti_bin/UserProfileService.asmx”
Connection
Step 2 – Select the method GetUserProfileByName.
Method
Click next next and finish the wizard with the checkbox for “Automatically retrieve data when form is opened” checked.
Step 3 – In your form, goto the properties of your name textbox. In the ‘Default Value’ part, click the ‘fx‘ button next to the ‘Value’ field.
txtbx1
Step 4 – Click Insert Field or Group
Insert
Step 5 – In the data sources drop down, select GetUserProfileByName data source.
Keep expanding the groups under the ‘dataFields‘ group, and choose the ‘value‘ field.
setval1
Step 6 – 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.
setval3
Let the second drop down be unchanged (is equal to).
In the third drop down, select “Type Text…” and write “PreferredName“.
setval4
This third drop down will decide what property is to appear in your textbox. For email, 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“.
Step 7 – Close all open dialog boxes by clicking ok.
Step 8 – Preview to see the output.
Prerequisite : UserProfileServices should be configured in your environment.
Below is a list of few properties that are returned by the userprofileservice.
AccountName
FirstName
LastName
PreferredName
WorkPhone
Office
Department
Title
Manager
AboutMe
PictureURL
UserName
Assistant
WorkEmail
CellPhone
Fax
HomePhone

Comments

Popular posts from this blog

Clearing the Configuration Cache for SharePoint

SharePoint 2013 REST API CRUD Operations

Add List Item Attachments to Task Form using Nintex Workflow and Forms