Tuesday, 8 November 2011

InfoPath 2010 - Using UserProfileService.asmx

“This blog details the steps for using the user profile service.  Click here for details on how to create a connection to retrieve information”

The following steps outline how to pull through the logged in users “preferred name” from the User Profile Service web service.

STEP 1 

Right click a field within the fields data source and chose properties

1

STEP 2

Within the text box properties window click the formulas button

2

STEP 3

Within the insert formulas window click Insert Field or Group

3

STEP 4

Within the Select a field or group window choose the GetUserProfileByName data source.  Expand the data fields and select Value then click Filter Data

4

STEP 5

Within Filter data click Add

5

STEP 6

With specify filter connection window click Select Field or group

6

STEP 7

Within Select a field or group window select Name and click OK

7

STEP 8

Within the specify filter conditions window enter a text filter: e.g “PreferredName”

Then click OK

8

STEP 9

The filter window should now show the following:

Name = “PreferredName”

Within the filter data window click OK

9

STEP 10

Within the Select a field or group window click OK

10

STEP 11

The insert formula window should now show:

Value[Name="PreferredName"]

Click OK

11

STEP 12

The text box properties window should now show formula.  Then click OK

12

As well as the preferred name other information you can get from the user profile service are include in the table bellow:

AccountName
FirstName
LastName
WorkPhone
Manager
UserName
WorkEmail

5 comments:

  1. Another great post. Thanks! Got it working off these instructions straight away!

    ReplyDelete
  2. how do i also retreive the information based on the employee selected in a people picker

    ReplyDelete
  3. When I do this, I end up with DOMAIN\Username. If I don't set the default values, I can type in my full name, and click check, and it displays the full name, but if I autopopulate it, it's only showing domain\username, even when I specify "PreferredName". Is this just how the accounts are set up in my Sharepoint Server?

    ReplyDelete
  4. Glad to know this works in 2010. Should someone by kind enough to answer... My 2007 form works fine in the preview, yet when I try to duplicate this in a new infopath 2010, form, it fails in preview but works if you open the published form in sharepoint. Here is the error:
    The SOAP response indicates that an error occurred on the server:

    Server was unable to process request. ---> Attempted to perform an unauthorized operation.
    Any thoughts ?

    ReplyDelete
  5. When I do the above I am able to get the Preferred Name SOMETIMES. It works then it does not work then a few hours later it works again with no changes. I have increased my Data Connection Timeout and also make sure the app pool service and the userProfileService in Central Admin have the same permissions. Do you have any idea why? I have been searching for days for an answer.

    Note: when I create the data connection in infopath it asks for my credentials, I type them in however they do not take, (asks again) I hit cancel and it lets me continue and it creates the Data Connect

    Using: Infopath 2010, SharePoint Enterprise 2010

    Any help would be a great help.

    ReplyDelete