Wednesday, May 23, 2007

People Picker Control for Infopath 2007

Ever wanted to have a people picker kind of control in Infopath form and that too in browser mode. Did i heard yes :) , well there is a Active-X control which takes care of this part named "Contact Selector Control".

Just follow the steps to get it working :

Add Contact Selector to Controls Pane

  • Click the "Add or Remove Controls " from the Control Task pane as shown in figure





  • Click ADD
  • Select Active-X
  • This will display a list of controls , select "Contact Selector" ,click Next
  • Select "Don't include a .cab file"
  • From drop down select "Field or Group(any data type) and click finish

DataSource for the Contact Selector control

  • Add non Repeating group named "group1"
  • Add a repeating Group names "Person"
  • Add following test field to the "Perosn " group (DisplayName,AccountId,AccountType)


Add Secondary datasource XMl file with details about the SharePoint Server , this is required by the form in order to validate the user against a particular sharepoint server .

  • Open Notepad and add the following Tag <Context siteUrl="http://<servername>"/>
  • Save the file as Context.xml
  • Add new connection as "Receive Type" and source of data as "XML"
  • Option “Include the data as a resource file” shoule be enabled


Drag control to the form and you are all set .


Best of Luck !!!!

32 comments:

Ryne said...

I can not get this to work. I have set it up just as you described, however, it will not verify the names against the server. it just says "search failed"

I am wondering if this is because I can not view the pictures on your tutorial. Please let me know if you can change those links. Thank you

Anonymous said...

same here , just get a "search failed" message...

i can see the images and was able to follow the example...

any other ideas
thanks in advance

Dunia seluas daun kelor said...

thankz u, it's very usefull, now i can use it for creating user request approval. can i translate it in bahasa in my blog

Anonymous said...

I have managed to get this to work and the names are coming through ok but when I add the names the field greys out and nothing appears. Any ideas?

Parin Shah said...

This works great! But when I want more than one people picker, it keeps putting the same exact person in both fields. Currently both of my fields are being binded to group1. Any ideas how to have two separate people pickers?

rakesh said...

i cant get this work either It says serach failed. can you pls help me out.

sithu4u said...

I am unable to work as i am getting the message "Search Failed" message.

Raghu Iyer said...

Please check your search configuration

Anonymous said...

The people picker control works great but has anyone figured out how to have two people pickers within the same form?

alx said...

more than one field is not that hard. simply create a new group for the new contact, and then right click on the exiting Person group, click reference and point it to the new group. That will copy the person xml structure under the new one. and you're set to go.

Anonymous said...

Data connection name appears to be case-sensitive. 'Context' worked, but 'context' did not.

Himanshu said...

For those guys who are not able to get the contact selector to work. The Contact Selector control needs to know the “context” of where the user validation should occur. It will automatically work if you are only displaying the form in a browser from SharePoint , it uses the context of the site from where it was provisioned; however, if you are in a mixed client/browser scenario you will need to include an XML file so forms opened in the client can use this functionality. Find the XML file in this link- http://blogs.msdn.com/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx

ROver said...

Thanks - works like a champ. For those that couldn't get it to work...you have to (1) label everything exactly like the tutorial and (2) drag and drop the "group1" as a contact selector. Everything should work then.

Dandle said...

I tried to store a boolean in the Person repeating group, but it is greyed out at runtime.

Does anyone know why this would happen or how I can fix it?
Thanks in advance.

Daniel said...

Can I just point out to people to make sure and try publishing the form and running it to test your Contact Selector. Running it in preview proved to show "Search Failed" but when I published it and ran from SharePoint, it worked like a champ. Just thought I would save the trouble for some folks :)

Fougere said...

Hi,
This tutorial is very clear, and I believe that I have exactly followed the directions. However, even though my form is posted and lives in a Sharepoint Forms library (and I'm opening directly from the library) -and my search is successful, after I click Add and OK on the userid that was found, the field is grayed out, rather than the data showing up. I would so appreciate more help!

Raghu Iyer said...

Fougere,

Are you using internet explorer? I have never seen such issue .

I had some problems with firefox and safari browser.

Anonymous said...

Are there other fields that you can pull back like "title", "Phone", "email"...etc....?

Brett said...

Does this person picker control work on web-based infopath forms??

Raghu Iyer said...

Yes Bret , it works in browser too.

Jason said...

If you are finding that the field is grayed out after selecting a name you need to move the repeating group (AccountId, AccountType and DisplayName) to be under the contact picker group.

ehaze said...

is there a way for the control not to show the words e-mail addresses?

rick said...

thanks for the update on the grayed out box. this thing works great!

Qassem said...

For any one face Error "Search Faild" be sure from Context.xml file

Anonymous said...

Is there any way to hide or remove the 'To...' button from this control please? :-) Great tutorial thanks!!

Jim Adcock said...

Thank you Raghu for the post! Works GREAT!

Thank you alx (Alex Dean) for help with "Reference" for multiple pickers!

Chopped Liver said...

It worked for me and I am so grateful! Thanks for the tip.

chandrika said...

Hi,
even i am facing the Search failed error..Please help

Anonymous said...

For those of you who are facing the control being greyed out problem, double check your spelling and the order of Data source items as shown in tutorial.

Anonymous said...

This is great!! thank you! I had the gray out problem and solved it by checking the spelling and making sure I had BOTH groups (including person inside group1).

Carol said...

I was able to create the people picker. I published it to SharePoint 2007.
It allowed me to pick the contact from our outlook list, but when I clicked ok I recieved an error message:
"An error occured while the form was being submitted"
Is there something I can check to fix this problem?

Tom said...

My problem with the control is the same as described by Carol; when I select a name and try to add it to the field attached to the control, that action causes the whole form to be submitted prematurely and I get a submission error. How can you add a name without it affecting the web page to server submit process?