Requirement
Create an Infopath that allows a user to look up the manager of an employee from AD using a People Picker field in Infopath.
Solution
Create 3 fields:
- Employee Name (People Picker)
- _EmployeeName (Text string, Hidden)
- Manager (Text string, Visible)
Create a data connection to the user profile service of your SharePoint site. This is done by adding a SOAP Web service definition.
- Open Infopath, click on the Data tab
- Select Data Connections
- Click Add
- Select Create a new connection to: Receive data
- Click Next
- Select SOAP Web service
- Click Next
- Enter the URL of the SOAP Web service definition. It is normally in the following format:
- http://<sitename>/_vti_bin/UserProfileService.asmx?WSDL
- Select an operation: GetUserProfileByName
- Click Next
- Parameters: leave as default
- Click Next
- Store a copy of the data in teh form template: Unchecked
- Click Next
- Give your connection a name, we will use the default: GetUserProfileByName
- Automatically retrieve data when form is opened: Unchecked (Important).
Set up the 3 Infopath fields you created as follows:
Employee Name (People Picker)
Ensure that you can query your SharePoint site for users. You can do this by ensuring that you specify your SharePoint server in the field properties.
_EmployeeName
Set the default value of the field to: substring-after(AccountId,”\”) where AccountID is from the Employee Name (People Picker) field.
Add 2 rules fo the _EmployeeName field.
Rule 1:
Action: Set a field’s value
Field: Select AccountName from the GetUserProfileByName data connection.
Value: _EmployeeName (Field)
Rule 2
Action: Query for data
Data connection: GetUserProfileByName
Manager
Set the default value of the Manager field to look up the GetUserProfileByName data connection and filter the Manager field from AD.
Done. Once all 3 fields and your data connection has been set up correctly. You will be able to query AD for the manager of any user you specify in the people picker.
Applies to:
Infopath 2010
SharePoint 2010
Great article man, thanks
you dont realsie how much you just helped me!
Thanks!