Using multiple Contact Selector controls in a single InfoPath form

I know what you’re thinking ….”Wooohooo … yet another article from Martin about InfoPath and the Contact Selector control!”. I know I’m sounding a bit like a broken record with this particular topic right now but there are lots of useful tips to share about this control and how to get the best of it.

If you are unsure what I mean by Contact Selector control it is a neat control that allows you to select users from a GAL-style interface within an InfoPath form:

ContactSelector_ControlCABI7BGR

These links provide useful reference for how to use the control

My own article: Top Tips for InfoPath form development with SharePoint: Part 1 (look for tip 4)

The InfoPath Team Blog: Using the Contact Selector Control

MSDN: The Contact Selector Control

In some types of form it may be necessary to have multiple instances of the Contact Selector control. For example an expenses form where you need a Contact Selector for the claimer's name and another for the approvers’ name.

One of the issues with the Contact Selector control is that it is not immediately obvious how you use multiple instances of it within the same form. This is because the control itself has to be bound to a very specific data structure and the naming of this data structure must be exact in order for you Contact Selector to work properly.

The way you achieve multiple instances of this is to built the data structure once and reference it to other parts of the form’s Data Source. You do this by following these steps:

1. Built the ‘source’ structure at the root of your form’s data source to look like the image below (naming, structure and capitalisation need to be exact!)

ContactSelector_SourceStructureCABVF26G

2. Create folders for each of the Contact Selector instances that your require. in our example this would be ‘Claimer’ and ‘Approver’

3. Reference the source structure to the folder you created in step 2. This is achieved by right-clicking gpContactSelector > Reference > Choose the folder you want to reference to

4. Add the Contact Selector controls to your form (from the Toolbox, if they do not shown up, read this article) and bind them to the  referenced gpContactSelector folder beneath the folder that represents the field the form need to capture information for. For example the ‘claimer’ should be referenced to <root> / Claimer / gpContactSelector. Your final form should look like this (shown in Visual Studio 2008):

ContactSelector_FullStructureCAG0Q416

That is it, you are now done and both Contact Selector controls can independently store data in your form.

If you would like a copy of teh XSN for this article, please contact me using the details below.

This article was published by

MartinKearn

Martin Kearn Senior Consultant Microsoft Consulting Services UK Martin.Kearn@Microsoft.com

Click here for my bio page