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 5 and 5 and type the answer here:
  • Post
  • Hi dvn,

    This was discussed in the comments as my initial statement was not clear: the template part you create is just the "data structure" which you could then bring into your XSN. You cannot add the control itself to the template part. (Refer to my comment on Apri 16, 2007.)

    Scott

  • I apologize for having so many questions.

    I tried your validating event code for limiting the Contact Selector to one entry.  If I search and add 2 entries, the validation dashed red box does not show up unless I click check names.  Did I do something wrong, do I need to add something, or is there no way around this?

    Thank you for all of the help.  I really do appreciate it.

    Nick H

  • Hi Nick,

    No problem - glad I can help!

    Unfortunately you need to validate the user. You can see this if you drah the "Person" node to your view as a Repeating Table. That data structure does not get populated until you validate the user or users selected. And so that you are aware, the same is true if you reverse the process: if you select a user and then just delete the name from the Contact Selector control, it does not get removed from the Person node until you validate the fact that you deleted the name.

    Scott

  • I have an infopath form with contact selector serving as a workflow modification form. But when I click link to open this form it leads me to the sharepoint page showing "Unknown Error". This form works fine in Non shrepoint environment even I have tried it using as Task Form. It creates problem only while used as modification form. I have tried diagnostic logging as well but no log entry is generated for this error.

  • Hi Sono,

    If the InfoPath form works fine outside of your workflow then your best option will be to post your question to a SharePoint workflow forum or blog as we do not handle workflow issues.

    Scott

  • Hi, this is a great article. Although I found a tiny itty bitty problem. We are using this example to create a service form. Someone makes a request and uses the selector to make choose someone to be assigned this request to.

    I have a View for this form where people view requests filtered on the selectors extracted column is equal to [Me]. We then create Alerts from this View to alert our staff when something is assigned to them.

    However, when I publish the form, the best I can use is 'Display Name' to filter on but this gives an error when creating the view. It does not allow filtering on 'Display Name' because is multiple lines of text and using begins with or contains produces a render fail on the results of the view, hence stopping the alert. Is the anything I can do to have the column type for the contact selector form be extracted as a type 'Person'.

    Is there a better way about going with this?

  • Hey fraygos,

    I am new to Infopath so I doubt I can be of much help.

    A good way to understand the Contact Selector is to drag and drop gpContactSelector into your form and select "Repeating Table".  Essentially, the Contact Selector adds a row and fills in the row's values every time a contact is selected with the control.  

    I looked all over the Internet to find a way to try to get data from a specific row/column of a repeating table/field but I did not find anything.  Maybe you know how to do this.

    Anways, I'd bet that the infopath team will help you with your problem shortly.

    Nick H

  • Hi fraygos,

    Unfortunately there is no out of the box way to promote a column as Person/Group or bind to an existing column as Person/Group. However, what I have done to get this to work is to use SharePoint Designer to add a workflow to the library where I have created my Person/Group column and then use the workflow to set the value of my Person/Group column to the "AccountId" field that I promoted from my InfoPath form.

    I hope this helps!

    Scott

  • ^That helped me a lot Scott.  Thanks.

    Nick H

  • I have found 2 roadblocks to using the InfoPath Contact Selector in browser-based forms. These seem to be bugs...

    1)In both Safari and Firefox 3.5, when the Contact Selector checks to make sure the name entered is in AD, it adds an empty user and then pops up a dialogue box to resolve the empty user. ex: " ; LastName, FirstName" (without quotes) is what is in the field. IE 7 and 8 do not do this.

    2)In Safari, once you add a user, you are unable to delete that user. You can delete the user in FF and IE.

    Are these reported bugs, and will they be resolved anytime soon? This is unacceptable behavior for the control. Our clients are not happy with it, and neither are we.

  • Hi mat1583,

    Thank you for bringing these issues to our attention. I searched through prior support cases we have received and was unable to find where this behavior had been brought to our attention before. So the first thing I want to let you know is our product group was not aware of these behaviors.

    I have been able to reproduce the behavior you describe in both Firefox and Safari and will be submitting these to the product group for review. However, I don't have a time frame on if/when this may be addressed.

    Thanks again,

    Scott

  • Thanks for the reply, Scott. I was able to workaround the 'can't delete' issue by adding a clear button which uses a rule to clear AccountID, DisplayName, AccountType and reset our user count (since we have validation to limit to only 1 user). Safari and FireFox together make up a third of our traffic, so the extra blank user problem could be pretty confusing for a lot of people. This post was EXTREMELY helpful for me, but it was a big disappointment to get this far and discover problems like this. Hopefully it will be resolved soon. I'd love to use it in other forms we're developing if it will function correctly in other major browsers.

  • Thanks mat1583 - I am glad you found this useful!

    I have submitted this behavior to our product group so hopefully this is something we can look at for a future service pack.

    Scott

  • Hi!

    I'm working with an InfoPath form which must have some Contact Selector controls to validate users from the MOSS server's AD.

    I've done all steps as they're explained in this post, but the contact selector does not validate any user, and when I try to search for users clicking on the "To" button, it could not search for them.

    I've already tried to change server name with IP address in Context.xml, but still can't search or validate users.

    What could be the cause of this problem?

    Thanks in advance.

  • Hi minhasquier,

    Can you verify that the node names in your data source are spelled correctly AND the capitalization matches what is in this post?

    Scott

Page 22 of 27 (398 items) «2021222324»