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
Popularity: 100% [?]
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.
i am getting search failed , everything is right but still to getting error
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
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.
Your post was perfect! Thanks heaps!!!!
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?
I got that working - all sorted - thanks Paul
Hello, is it possible to show other fields like department or phone?
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
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.
Hi Ulysses,
Excellent article. Just what I was looking for.
Thanks
Snehal
How do I have multiple People Picker on the same form?
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,
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.
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
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
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
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
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
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.
Hi.
Nice post.I got it working.