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.
I renamed the 2 groups in the datafields like shown below (CurrentUser and Manager):
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
In the next screen select the method GetUserProfileByName and finish the wizard.
Now lets go to the interesting part.
Open the form load rules task pane from the ribbon:
Add following Rules now:
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()
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).
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:
This one is just executing the web service but this time with the manager’s account name (see picture in Rule 1).
These rules are setting the values for the Person/Group Picker of the manager.
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: