Home > Infopath, SharePoint > Getting Infopath 2007 talk to Sharepoint’s “UserProfileService”

Getting Infopath 2007 talk to Sharepoint’s “UserProfileService”

Requirement: If you wanted to read any information about the user (example: Preferred name, Phone) based on the the login id then querying for Sharepoint’s “UserProfileService” would be an ideal option.

The “UserProfileService” can be found at:

http://<server>/_vti_bin/UserProfileService.asmx

or, if it’s a sub-site

http://<server>/<site1>/_vti_bin/UserProfileService.asmx

From your Infopath 2007 Form:

Goto Tools -> Data Connections -> click "Add" to open up "Data Connection Wizard".

Select "Create a new connection to: Receivet data" and click "Next" button.

Select "To a Web service" under "How do you want to submit your data?" and click "Next" button.

Specify full URL for the "UserProfileService" web service and click "Next" button.

Select "GetUserProfileByName" under "Select an operation:" and click "Next" button.

Do not specify any value (" Do not click on the 'Set Value' button") and click "Next" button.

Make sure that "Store a copy of the data in the form template" remains unselected and click on "Next" button.

Enter a name for this data connection and ensure that the "Automatically retrieve data when form is opened" is unselected and click "Finish" button to close this wizard.

Click "Close" button to close the "Data Connections" window.

In a real-time scenario lets say, we need “WorkEmail” for the given “UserName”:

From Rules window, click "Add" button to open "Rule" window.

I am not setting any conditions for this rule.

Click "Add Action" button to open "Action" window.

Select "Set a field's value" under Action, Click on the icon button under Field to open "Select a Field or Group" window, choose the data source (the name specified under data connections for "GetUserProfileByName").

Navigate myFields -> queryFields -> s0GetUserProfileByName -> select "AccountName" and click "OK" button.

Enter / Type "userName()" under Value and click "OK" button.

Click "Add Action" button again to open "Action" window.

Select "Query using a data connection" under "Action" and choose the data source (the name specified under data connections for "GetUserProfileByName") and click "OK" button.

Click "Add Action" button again to open "Action" window and Select "Set a field's value" under Action and choose "your" desired field under "Field".

Click on the "fx" button under "Value" to open "Insert Formula" window.

Click on "Insert Field or Group" button top open "Select a Field or Group" window.

In "Select a Field or Group" window, choose the data source (the name specified under data connections for "GetUserProfileByName") and navigate to "myFields" -> "dataFields" -> "s0:GetUserProfileByNameResponse" -> "GetUserProfileByNameResult" -> "PropertyData" -> Select "Name" and click on "Filter Data" button.

In "Filter Data" window, Click "Add" button to open "Specify Filter Conditions".

The first drop-down contains "Name" by default, choose "Select a field or group" to open "Select a Field or Group" window.

Make sure that the Data source points to the "GetUserProfileByName" data source (the name specified under data connections for "GetUserProfileByName") and navigate to "myFields" -> "dataFields" -> "s0:GetUserProfileByNameResponse" -> "GetUserProfileByNameResult" -> "PropertyData" -> "Values" -> "ValueData" -> select "Value" and click on "OK" button to return to "Specify Filter Conditions" window.

The next drop-down is set to "is equal to" and for the third drop-down, type text "<em>WorkEmail</em>" and click "OK" for all the open windows until you exit the "Rules" window.

Note: in our example here, we have used “WorkEmail” to get the Email address, likewise we can specify FirstName, LastName, PreferredName, WorkPhone, Office, Department, CellPhone, Fax, HomePhone, etc.

Advertisements
  1. Anonymous
    July 27, 2011 at 6:02 PM

    Thank you! Just what I was looking for!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: