Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Using the Contact Selector Control

Using the Contact Selector Control

Rate This

(This post applies to InfoPath 2007. If you're using InfoPath 2010, then you should check out this post instead.)

We have seen a number of requests on how to allow a user to enter (or select) a person’s name or logon alias and then validate that user against their Active Directory without using code. This has been especially true in workflow scenarios where User A needs to enter in the name of User B – the next person in the workflow process.

Well, InfoPath 2007 ships with a control called Contact Selector Control that will resolve these issues! You may have seen our older article on the subject; this one aims to dive in deeper.

The Contact Selector control is an ActiveX control but it is a special cased control, in that it can also be used in InfoPath browser forms. To use this control there are specific steps that need to be taken – let’s take a look at those now.

Step 1: Add the Contact Selector control to your Controls Task Pane

1) From the Controls Task Pane click the Add or Remove Custom Controls link

2) Click the Add button

3) On the first screen of the Add Custom Control Wizard select ActiveX control and click Next

4) From the list of controls, choose Contact Selector and click Next

5) Select “Don’t include a .cab file” and click Next

6) For Binding Property select Value and click Next

7) From the Field or group type box choose Field or group (any data type) and click Finish

8) Click Close and then click OK


Step 2: Create the data structure for the Contact Selector Control

The Contact Selector control needs to have a specific data structure to work properly – this is documented on the “Items” tab of the Properties screen for the control; however, we’ll include that information here as well.

**IMPORTANT!** Spelling and capitalization must be exactly the same, starting with the “Person” group!

1) Add a non-Repeating Group named: gpContactSelector

2) Add a Repeating Group named: Person

3) Add the following 3 text fields to the Person group: DisplayName, AccountId and AccountType

Step 3: Add and bind the Contact Selector control to the View

1) Drag the gpContactSelector Group to the View and select “Contact Selector” from the list of controls

2) You’re almost done…! :-)

Step 4: Add a secondary data source XML file which specifies the SharePoint server

The Contact Selector control needs to know the “context” of where the user validation should occur. These steps are not necessary if you are only displaying the form in a browser from SharePoint – in this case, 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 this XML file so forms opened in the client can use this functionality.

1) Launch Notepad

2) Copy and paste this one-line XML:

<Context siteUrl="http://<servername>"/>

**NOTE: Replace <servername> with the name of your server

3) Save this as: Context.xml (again – naming and capitalization are important)

4) Add Context.xml as a “Receive” type Secondary Data Connection to your form template and make sure the option “Include the data as a resource file” is enabled

Step 5: Test!

You should now be able to Preview the form, enter a name or logon alias, click the “Check Names” button and resolve the name! Alternatively you could click the “To” button to perform a Search if you do not know the complete name of the user.

One other important point: if this control is something you will use numerous times, this process works great to create a “Contact Selector Template Part” – then you only have to complete these steps one time!

Scott Heim
Support Engineer

Leave a Comment
  • Please add 2 and 2 and type the answer here:
  • Post
  • Disregard!  I read further down to a post by Meghan on May 17 and I had the same problem.  Bad spelling/capitalization.  Talk about picky Infopath forms!  :)

    Thanks again, this is a huge lifesaver!

  • Awesome post.  Here’s a tool that lets you build all types of web forms with email alerts fast and without coding. Just point and click

  • If this control could also return users' phone numbers from the SharePoint site, that would be ideal.

  • hi Scott

    i hope you are still here and can help me :D

    i have several contact selectors in my infopath form. i have been trying to set default valu for all of them, but it is not working.

    first i was trying it with the resolveprincipal data connection (people.asmx) and add those six rules for each contect selector in the Tools menu choose Form Options -> Open and Save. when it is all done i set the domain\username for all cotact selector's display name and after i publis it to a sharepoint server and create a new document all contact selector are epmty, except those which has my name in it. so i create a new document, i save it, and when i open it all contact selector are empty.

    second i was trying it with the getuserprofilebyname data connection and set all 3 nodes:

    DisplayName - use the PreferredName attribute from the UserProfileService GetUserProfileByName web method

    AccountId - domain name of the user in the form domain\username (can manually concatenate your doman name + \ + userName() or use the AccountName node of the GetUserProfileByName web method

    AccountType - Just the word "User" is fine if it's a user

    when its done, the contact selector has the domain\username but it does not resolve it.

    please help me. i have been trying to figure this out for 2-3 days and grrrrrr :D

  • i think easy to pratice your..... explanation step by step thanks

  • Hi BearCheese,

    Sorry for the delay...are you using InfoPath 2007 or InfoPath 2010? And if 2010, are you saving the XSN in the new 2010 format or the 2007 format?


  • Hi Scott

    Thanks, but i managed to make it work. actually its very easy. all i needed to do was retrieving data from active directory by getuserprofilebyname.

  • Hi,

    I have tried all the steps above with InfoPath 2007. I started from scratch and have nothing else but the contact selector as the only data source.

    When I try to preview the form with the ContactSelector in the View I get

    "InfoPath cannot open the selected form" error message. But when I remove

    it there is no error message.

    Also I believe the ContactSelector control is meant to have a text box with and "To..." button to the left. But in my case it just a small square with a red dot inside of it (looks like a image place holder)

    Please can you tell me where I may have gone wrong? Spent so much time on this, would be grateful for some help.

    Many thanks!

Page 27 of 27 (398 items) «2324252627