Unfortunately, there is no easy way to do this, the only way to do this is to wire in a simple web service query that pulls the necessary information when a user chooses a name in the people picker. Upon selection, the web service call is made, returning data to the GetUserProfileByName data connection, the resulting data in the GetUserProfileByName data connection can be diligently filtered and used to set the values of fields in the main data connection.
Open InfoPath and select Tools >> Data Connections
Create a new data connection
Choose Web Service
Enter the URL to the UserProfileService.asmx web service (hint, test this in a browser, if it doesn’t work there it certainly will not work in InfoPath)
Choose the GetUserProfileByName operation
Note the parameter, you will not need to enter a default value
** Hint: If you run the GetUserProfileByName without specifying a name, SharePoint will return the profile data for the currently logged in user.
Do not store a copy of the data in the form template
You can rename the operation here but I recommend leaving it exactly as is
Now note the data connection in the data source view
Now we are going to try creating a data connection from infopath that queries this web service, some of your users might see the warning below when testing with their personal accounts.
To grant users rights to query the profile database open “Central Administration” and select your shared services provider (take care not to accidentally expose profile data that you would not normally like to share)
Under User Profiles and My Sites select “Personal Services Permissions” and grant your users, such as domain\domain users, rights to read user profiles
** If the rule does not trigger for the AccountId field try adding it to the Person group
We are going to set the value of the queryfield in the secondary data source called GetUserProfileByName to the value of the AccountId field in our people picker’s data structure. After that we will query the GetUserProfileByName then set the Employee’s Department equal to the Value returned (note that we need to filter the PropertyData, more on that later)
Create a rule on the AccountID field called GetEmployeeProfile
Set the value of the secondary data source GetUserProfileByName to the AccountID
** Hint, the AccountId can be any field that contains the user’s username
The next action in the rule should query the GetUserProfileByName data connection
Filter the ValueData where the “Name” field equals the user profile property name such as Department (note that you could do this for Title, WorkPhone, Manager, etc. as long as that field is a property in your profile database)
Our filter condition will appear as follows
After selecting OK our filter data now appears under existing filters
Click ok again and you can see that we are asking the profile datasource for the ValueData.Value where the PropertyData.Name equals “Department”
After all that you can see that we are setting a field in the main data source to a value we located in a secondary data source called GetUserProfileByName
The resulting rule will appear as follows
Note that the query does not work across domains!!!
Hint: If you run the GetUserProfileByName without specifying a name, SharePoint will return the profile data for the currently logged in user… this is useful for pre-populating the form on open.
Rating: 8.9/10 (14 votes cast)
Rating: +4 (from 4 votes)
Querying SharePoint Profile Data from an InfoPath Form, 8.9 out of 10 based on 14 ratings
Ulysses Ludwig is a SharePoint architect with over 16 years in the IT and computer industry. Ulysses' primary focus is SharePoint but he dabbles in the latest web technologies and likes to develop software in his spare time.
Sometimes InfoPath doesn’t allow you to rename your main data source so you are stuck with a name that doesn't necessarily match with the function of the form. This is very common for those of us that...