Adding a Contact Selector/People Picker to an InfoPath Form

Problem

You want to use the People Picker functionality in InfoPath that SharePoint supports natively.

*** Look for the common mistakes section at the bottom of this article ***

*** To query additional information about the selected user see this article: http://www.sharepointassist.com/2010/02/02/querying-sharepoint-profile-data-from-an-infopath-form/ ***

Solution

Follow the steps very carefully below.  It takes a lot of steps to get the contact selector working in InfoPath but once you get it working you shouldn’t have any problems doing it again.  Note that the example below assumes you are using InfoPath 2007 and that you have access to a SharePoint server.

Create a new form in design mode

clip_image001

Open the task pane by pressing Ctrl-F1 or View >> Task Pane

clip_image002

Select Controls in the Design Tasks window

clip_image003

If you do not see the contact selector under Custom you will need to add the ActiveX control for the first use. Scroll to the bottom and select Add Remove Custom Controls.

clip_image004

Select Add or Remove Custom Controls… and the custom controls window will appear. Select Add.

clip_image005

Choose ActiveX Control

clip_image006

clip_image007

Do not include the cab file

clip_image008

Select Value in the bind to property

clip_image009

Select Field or Group in the Specify Data Type Options screen

clip_image010

Now that you’ve successfully added the contact selector to your available Infopath controls let’s go ahead and add the control to our form

clip_image011

Double click on the newly added control to view its properties. Select the Items tab. This displays the schema that the contact selector expects, it’s case sensitive so take care (consider taking a screenshot). If you read this tab carefully it tells you everything you’ll need to do in order to get the contact selector working.

clip_image012

Unfortunately, InfoPath doesn’t create this schema for us so we will need to add it to our data source by hand. In the tasks pane select Design Tasks then select Data Source .

clip_image013

In the Data Source window right mouse key on the contact selector’s group and add the Person group as a repeating group.

clip_image014

DisplayName

clip_image015

AccountId (note the “d” is lowercase)

clip_image016

AccountType

clip_image017

The resulting structure should look like this. You can rename group1 and then promote it to a person column in SharePoint

clip_image018

Now you will need to configure a secondary data source for the server context. You will first need to create an XML file called Context.xml as required by the contact selector.

clip_image019

Save the file as “Context.xml”

clip_image020

Within InfoPath select Tools >> Data Connections

clip_image021

Add a new data connection to receive data

clip_image022

Select XML document

clip_image023

In the XML data file details window select Resource Files and add the Context.xml document you previously created.

clip_image024

Leave the name as Context

clip_image025

Complete the Wizard

clip_image026

Preview the form

clip_image027

Common Mistakes

If you received a “Search Failed” message don’t worry, this is normal. You most likely have a typo in the Context.xml or you made a small mistake creating the data source.

  •  
    • Remember that the data source for Context is receive.
    • Make sure the Context.xml is well formed (the context tag must have an end tag)
    • Make sure the data source is named Context
    • Make sure you spelled all of the field names correctly
    • Make sure that the person field is repeating
    • Validate the binding of the contact selector control, it should bind to the parent of the Person group
VN:F [1.9.1_1087]
Rating: 8.9/10 (15 votes cast)
VN:F [1.9.1_1087]
Rating: +4 (from 6 votes)
Adding a Contact Selector/People Picker to an InfoPath Form, 8.9 out of 10 based on 15 ratings

Popularity: 100% [?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

35 Responses to “Adding a Contact Selector/People Picker to an InfoPath Form”

  • Tom Ostrem says:

    Ulysses,
    I have the contact selector working in a workflow.
    My problem is when I attempted to add another task to the workflow and utilize a second contact selector to assign a user to the second task.

    The element ‘gpContactSelector1′ in te namespace ‘http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-03-04T20:1828′ has an invalid child element ‘Person’ in namesapce.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Arokyaswamy says:

    i am getting search failed , everything is right but still to getting error

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • ujludwig says:

      This is common

      1) When testing try opening the form from a different machine in case the context data connection (that you added in context.xml) is not accessible
      2) Validate the context.xml from the resources in your infopath form. Make sure that it is well formed and that it contains an the end /.
      3) Replace the siteUrl in the context.xml with the IP address of your SharePoint server
      4) Make sure your infopath dataset has all of the correct names for the fields. For example, AccountId has a lowercase “d”. AccountName and DisplayName.
      5) Delete and re-create the contact selector, I’ve noticed sometimes that it just gets corrupted.
      6) Make sure the outer group is repeating (the group that contains the person group)
      7) It shouldn’t be an issue but you can try signing your form under Tools >> Form Options >> Security and Trust 8) Under security and trust make sure your form’s security level is set to automatic

      VN:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.1_1087]
      Rating: +1 (from 1 vote)
  • John says:

    Ulysses – Thanks for the great post on this. I successfully got two People Picker controls to work on my form with one modification to your instructions. I changed the Content.xml contents to and it worked.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Paul - Brisbane says:

    Your post was perfect! Thanks heaps!!!!

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Paul - Brisbane says:

    How do you get a sceond people picker working on a form (I am trying to get 3 on the one form) can you help?

    I can’t use the same names in the data sources, but the reference option tells me that the data will be the same…. can you explain how to get around that?

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Paul - Brisbane says:

    I got that working – all sorted – thanks Paul

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • pucki says:

    Hello, is it possible to show other fields like department or phone?

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Dave says:

    Hi,
    The fields in the group for the people picker are of type string. Is it possible, when the form is saved, to save it into a “people or group” type field in the library?
    I want to use it in a workflow to send an email.

    thanks

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • ujludwig says:

      Dave,

      I read your comment a few days ago and meant to test something but haven’t had a chance: I read somewhere that you can create a SharePoint designer workflow that copies the AccountID field to a “People” field upon change. In my case, however, I don’t remember this working so I went so far as to develop a “Person Converter” windows workflow foundation workflow capable of completing this action. I am currently packaging the item for sale as it provides additional functionality beyond the SharePoint designer option with respect to handling multiple users. Let me know if you are interested.

      VN:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
    • Benjamin says:

      Hi dave, I know, your post is quite a long time ago. But still, did you nmake this happen? I have the same troubles with getting my user information for a workflow and I am a little bit surprised that this seems to be so complicated.
      Thanks for your feedback,
      Ben

      VA:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Hi Ulysses,
    Excellent article. Just what I was looking for.

    Thanks
    Snehal

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • How do I have multiple People Picker on the same form?

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 2 votes)
  • AkS says:

    Hey,
    thanks for the great detaile post, I have checked everything & still getting Search failed. I have no idea what I am doing wrong.

    Regards,

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • minhasquier says:

    Hi Ulysses,

    I’ve the same problem as AkS, configured and re-configured everything many times, and stille getting “search failed”.

    Any idea should be welcome, thanks.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • ujludwig says:

      Try creating a receive data source that connects to the server upon open of your form, I’m curious to see if you’re having an authentication problem.

      Ulysses

      VN:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Ruth says:

    Great read…but I didn’t see a response to Pucki regarding selecting other fields within contact selector(e.g., email address)? any help would be appreciated!
    RC

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • GEM says:

      I want to know the solution also ~ Thx

      VA:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Adolfo says:

    Hi Ulysses,

    when I create the Contact Selector it seems to work fine. But once I search and add someone or type and click on the check button the field is greyed out and and I cant see anything. I also added DisplayName, AccountId and AccountType as columns in the SharePoint site and when I save the form those fields are all empty. Is that how it should behave or could I be doing something wrong?
    Thanks

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.1_1087]
    Rating: +1 (from 1 vote)
    • Andi says:

      Have you ever solved this problem?
      I am facing the same issue.
      Cheers
      Andi

      VA:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Jovix says:

    This is a great post and I am not getting the search failed error. however when I successfully search for a user name and click ok. The Selector is greyd out and the form errors when I hit submit. Any ideas?

    Thanks

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • M D says:

    Hi Dave,

    Thanks for this great posting! Saved my life…
    I was however having trouble saving it onto a “people or group” field in a sharepoint library. Do you have any idea how to go about it? I am sure your pointers will help me out.

    Thanks

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: +1 (from 1 vote)
  • Sean O. says:

    To use multiple pickers on one form: the problem is you can’t create another folder named “Person” so you have to reference the existing one. All you have to do is drag another control onto the form, then right click the existing “Person” folder and select “Reference” then select the group with the new control.

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Gautam says:

    Hi.
    Nice post.I got it working.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • GEM says:

    Hi Ulysses,

    Thanks for this great post!
    However how can I get the information besides DisplayName, AccountId and AccountType? Like the above example: http://www.sharepointassist.com/wp-content/uploads/2009/02/clip-image027.png, there is a “Title” field.

    Thank you for your help!

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Rusty says:

    Sorry to post the same question but I’ve gone over your list many times and everything seems right but it doesnt retrieve any names. Authentication is good – I tested with a Retreive Connection.

    The only thing that looks out of order is in the “Details” section of the Data Connections box (where you add, modify, etc).

    For the Context connection it shows “XML file: Context3.”

    I deleted and re-added the connection twice and it keeps incrementing the “XML file:” field.

    The file is named “Context.xml”.

    We do have a firewall but again I am able to connect.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • Rusty says:

      I fixed the “XML file:” naming problem – USER ERROR!

      Instead of clicking BROWSE I should have clicked RESOURCE FILE (As instructed).

      Alas – still a NoGo.

      VA:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
      • ujludwig says:

        I lead a training class a week or two ago and I noticed that 2 out of 3 participants had no problems whatsoever with the contact selector, however, there’s always that one machine that refuses to behave. Try a different build or machine and see if it works there, it’s terribly fickle.

        VN:F [1.9.1_1087]
        Rating: 0.0/5 (0 votes cast)
        VN:F [1.9.1_1087]
        Rating: 0 (from 0 votes)
  • Paul Baker says:

    Really helpful…had a few problems getting my capitalisation right on the xml file initially but your confident “don’t worry” section with common mistakes helped me press on!

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Jim Adcock says:

    Found my common mistake:

    Make sure that the person field is repeating

    oops.

    Your post helped, thanks!

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • Jim Adcock says:

      Oh, and just for completeness sake, the error message I was getting until I made Person repeating was:

      The element ‘elemnet′ in namespace ‘,em>namespave′ has an invalid child element ‘Person’ in namesapce.

      VA:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Leave a Reply:

    Name (required):
    Mail (will not be published) (required):
    Website:
    Comment (required):
    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>