Infopath – Looking employee’s manager in AD using People Picker

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:

  1. Employee Name (People Picker)
  2. _EmployeeName (Text string, Hidden)
  3. 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.

  1. Open Infopath, click on the Data tab
  2. Select Data Connections
  3. Click Add
  4. Select Create a new connection to: Receive data
  5. Click Next
  6. Select SOAP Web service
  7. Click Next
  8. Enter the URL of the SOAP Web service definition. It is normally in the following format:
  9. http://<sitename>/_vti_bin/UserProfileService.asmx?WSDL
  10. Select an operation: GetUserProfileByName
  11. Click Next
  12. Parameters: leave as default
  13. Click Next
  14. Store a copy of the data in teh form template: Unchecked
  15. Click Next
  16. Give your connection a name, we will use the default: GetUserProfileByName
  17. 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

 

Tags:

2 Responses to “Infopath – Looking employee’s manager in AD using People Picker”

  1. Boris October 16, 2011 at 4:14 am #

    Great article man, thanks

  2. Jamie June 12, 2013 at 4:50 pm #

    you dont realsie how much you just helped me!

    Thanks!

Leave a Reply

%d bloggers like this: