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 3 and 1 and type the answer here:
  • Post
  • The contact selector control in InfoPath 2007 is quite handy for users to select a person from active

  • Hi,

    Thanks for the wonderful tips on the Contacts Selector. I have used a contacts selector on a form and it works fine.

    However, I need the form to be submitted to a document library with a name generated from the user's name, and a link to the saved document to be sent to the person selected on the contacts.

    When using infopath, this works fine but when i publish the form and fill on the browser, it saves in the library but does not send e-mail.

    I am submitting the form using a rule that uses 2 data connections, 1 to submit to the library and 1 to e-mail.

    What could be the problem is not submitted to e-mail from the browser?

  • Hi levy,

    Keep in mind, when sending mail from a browser form it will be sent via the mail services setup on the server. Have you setup SMTP mail?

    If so, have you confirmed it is working? For example, can you add an "alert" to a list and actually get that mail?


  • Hi Scott,

    SMTP is currently configured on the server

    e-mails/alerts are going through. i just added an alert and received the notification

  • The data connection that sends the e-mail is set to "send only the active view ......". The summary after customizing is:

    Type: Submit Data

    E-mail Subject (expression): concat("http://enation2/SiteDirectory/HR/_layouts/formserver.aspx?XmlLocation=/SiteDirectory/HR/Investment%20Trust%20Fund/Monthly%20Contributions/", translate(MemberFullName, " ", "_"), ".xml&OpenIn=Browser")

    To (expression): DisplayName



    View Only

  • Seems like it should work - is there anything in your Application Event log or the SharePoint server logs or the SMTP service logs that would provide a clue?


  • 環境: Microsoft Office SharePoint Server (MOSS) 2007 Visual Studio 2005 SharePoint Server 2007 SDK and

  • 環境: Microsoft Office SharePoint Server (MOSS) 2007 Visual Studio 2005 SharePoint Server 2007 SDK and

  • Hi Scott,

    Question on resolving lastname, firstname in the contact selector.  I am populating this control via a database with a name and am having problems getting the name to resolve.  Even though the name should resolve it is only looking at the last name then automatically entering a semicolon -   lastname; firstname.  It is treating it as 2 different names.  I need this to resolve by populating the person's name so the person submitting the form can see who it's going to.

    I am using the GUI to design this browser form.  Please help!  


  • Hi cfarkal,

    As you have probably tested, it is not just when you programmatically set the name as: last, first - if you just type it in this way it does not resolve.

    The Contact Selector control is technically a SharePoint control and without debugging into the control, I am not sure why it does not like the name in this format. So - why not just format the name as: first last?

    Here is some sample code:

    XmlNamespaceManager ns = this.NamespaceManager;

    XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

    XPathNavigator xnCS = xnDoc.SelectSingleNode("/my:myFields/my:gpTasks/my:gpTask/my:gpContactSelector/my:Person/my:DisplayName", ns);

    string strName = "Heim, Scott";

    int intLoc = strName.IndexOf(",");

    string strFormattedName = strName.Substring(intLoc + 2) + ' ' + strName.Substring(0, intLoc);



  • Hi Scott,

    Excellent article! In the last paragraph, you suggested we could create a template part using the Contact Selector but I get "ActiveX controls are not allowed in Template parts" error when I try to add contact selector to the form. Could you kindly elaborate on how we can add contact selector to the template part?



  • Hi Daska,

    Yes - I should have been more clear on this - my apologies. What I was referring to was creating a template part of the "data source" - this way you don't have to keep recreating this each time. You can just add the template part containing the data source and just drag it to your View (it shows as a section.) Once there, just right-click on the Section choose Change To and choose Contact Selector!

    Saves a fair amount of time...


  • Thanks for the quick response Scott! I really appreciate it. It works but now the problem is that entering a value in one control shows that value in other controls too. For example, if i use the template part multiple times on the same form, then entering the value in one control populates all the controls on the form. How can I resolve this? I will appreciate your feedback on this.

    Thank you very much.


  • Ah - now that is a bit different! :)

    To use multiple Contact Selector controls, you would need to do this:

    - Add the Template Part *once* to your View and change it to a Contact Selector control as noted before

    - To add another one:

        - In the Data Source Task Pane, right-click on myFields and choose Add

        - Enter a name (i.e. CS2) and set the Type to Group (NOT repeating)

        - Expand the Template Part data source, right-click on the top group (i.e. gpContactSelector) and choose Reference

        - Select the new CS2 group and click OK. The appropriate data structure is added for you! Now, just drag the new gpContactSelector to the View and choose Contact Selector control.


  • Thank you very much Scott. It worked.



Page 3 of 27 (398 items) 12345»