InfoPath 2010 Get Manager Of Current User

Displaying the current user in an InfoPath 2010 form is not that tough, but how about the manager of the current user?
Well in this post i will show you how you can do that with rules and a SharePoint web service.

First of all put 2 fields of type Person/Group Picker into your form.
Form

I renamed the 2 groups in the datafields like shown below (CurrentUser and Manager):

DataFields

Now add a new data connection to receive data from a SOAP web service to your form and enter the URL to the Web service
http(s)://YourSiteURL/_vti_bin/UserProfileService.asmx?WSDL
In the next screen select the method GetUserProfileByName and finish the wizard.

GetUserProfileByName

Now lets go to the interesting part.
Open the form load rules task pane from the ribbon:

FormLoad

Add following Rules now:

Rule 1
Here we set the AccountName for which the web service will receive the data for.
As the AccountName value we can use the built in function userName()

click to enlarge
RuleAction1

Rule 2
As a second rule use the Query for data action and select the data connection of the web service which we configured before.
So we will receive the UserProfile information of the current user (see picture above).

Rule 3
This rule is the important one where we will set the AccountName for the web service query in order to
receive the profile properties of the manager of the current user:

click to enlarge
RuleAction3

Rule 4
This one is just executing the web service but this time with the manager’s account name (see picture in Rule 1).

Rules 5-7
These rules are setting the values for the Person/Group Picker of the manager.

click to enlarge
RuleAction5-7

So now when you open the form, the name of the manager is automatically set in the person picker field.


Below you will find some more properties which you can filter for in your InfoPath rules e.g. Value[Name=”PropertyName”]

So in the above condition you can replace PropertyName with one of these below:

  • AccountName
  • FirstName
  • LastName
  • PreferredName
  • WorkPhone
  • Office
  • Department
  • Title
  • Manager
  • AboutMe
  • PersonalSpace
  • PictureURL
  • UserName
  • QuickLinks
  • WebSite
  • PublicSiteRedirect
  • Assistant
  • WorkEmail
  • CellPhone
  • Fax
  • HomePhone
  • SPS-Dotted-line
  • SPS-Peers
  • SPS-Responsibility
  • SPS-Skills
  • SPS-PastProjects
  • SPS-Interests
  • SPS-School
  • SPS-SipAddress
  • SPS-Birthday
  • SPS-MySiteUpgrade
  • SPS-DontSuggestList
  • SPS-ProxyAddresses
  • SPS-HireDate
  • SPS-LastColleagueAdded
  • SPS-OWAUrl
  • SPS-ResourceAccountName
  • SPS-MasterAccountName