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 ***

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

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

Select Controls in the Design Tasks window

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.

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

Choose ActiveX Control

Do not include the cab file

Select Value in the bind to property

Select Field or Group in the Specify Data Type Options screen

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

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.

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 .

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

DisplayName

AccountId (note the "d" is lowercase)

AccountType

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

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.

Save the file as "Context.xml"

Within InfoPath select Tools >> Data Connections

Add a new data connection to receive data

Select XML document

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

Leave the name as Context

Complete the Wizard

Preview the form

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
a WordPress rating system
a WordPress rating system
Adding a Contact Selector/People Picker to an InfoPath Form9.0106

Popularity: 100% [?]

Share and Enjoy:
Share this Post:

21 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.

    a WordPress rating system
    a WordPress rating system
  • Arokyaswamy says:

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

    a WordPress rating system
    a WordPress rating system
    • 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 Under security and trust make sure your form’s security level is set to automatic

      a WordPress rating system
      a WordPress rating system
  • 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.

    a WordPress rating system
    a WordPress rating system
  • Paul - Brisbane says:

    Your post was perfect! Thanks heaps!!!!

    a WordPress rating system
    a WordPress rating system
  • 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?

    a WordPress rating system
    a WordPress rating system
  • Paul - Brisbane says:

    I got that working - all sorted - thanks Paul

    a WordPress rating system
    a WordPress rating system
  • pucki says:

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

    a WordPress rating system
    a WordPress rating system
  • 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

    a WordPress rating system
    a WordPress rating system
    • 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.

      a WordPress rating system
      a WordPress rating system
  • Snehal H. Rana says:

    Hi Ulysses,
    Excellent article. Just what I was looking for.

    Thanks
    Snehal

    a WordPress rating system
    a WordPress rating system
  • Snehal H.Rana says:

    How do I have multiple People Picker on the same form?

    a WordPress rating system
    a WordPress rating system
  • 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,

    a WordPress rating system
    a WordPress rating system
  • 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.

    a WordPress rating system
    a WordPress rating system
    • 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

      a WordPress rating system
      a WordPress rating system
  • 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

    a WordPress rating system
    a WordPress rating system
  • 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

    a WordPress rating system
    a WordPress rating system
  • 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

    a WordPress rating system
    a WordPress rating system
  • 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

    a WordPress rating system
    a WordPress rating system
  • 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.

    a WordPress rating system
    a WordPress rating system
  • Gautam says:

    Hi.
    Nice post.I got it working.

    a WordPress rating system
    a WordPress rating system
  • 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>