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 1 and 4 and type the answer here:
  • Post
  • Many of our users have multiple email addresses/user accounts. Is there anyway to get around this error:

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The form cannot be submitted because some of the e-mail addresses cannot be resolved. If you know the values in the form that specify the e-mail addresses, revise them and try again.

    The following addresses did not resolve in the To line: Bryan

    Is there anyway to point it to look at a particular OU or does it just point to the GAL? The GAL contains everyone worldwide and i want to be able to just have it resolve to our office or local address book.

  • I have read so many of your posts I feel like I know you and I can see that you have been hammered by the contact selector control.  Anyway -

    My question is two fold: After attempting to use multiple controls I realized I am unable to get supporting information.  Meaning the textboxes I am attempting to populate (i.e. Deapartment, WorkPhone) still bring up my info.  My 'hidden' text box does include the requested user's accountid (i.e. domain\user).  I am assuming I am not filtering correctly.  My desk has a permanent dent the size of my head.  Thanks for anything you can suggest - Scott Bernard sbernard@darden.com

  • sbernard,

    Sorry for the delay in responding...

    So it sounds like you are using the Contact Selector control to select a user then you want to get more information about that user using the GetUserProfileByName web method of the UserProfile web service - is this correct?

    If so, then you will want to verify a few things:

    1) The GetUserProfileByName data connection should not fire when the form first opens unless you need to get information first for the user opening the form

    2) When you click the button to get the details for the user you selected in the Contact Selector control, you need to make sure the first action in your button Rule is "Set a field's value". What you need to do here is set the "AccountId" in the queryField from the GetUserProfileByName data connection to the AccountId field value from the Contact Selector control.

    3) Once you have the AccoundId field populated, then you will query the GetUserProfileByName data connection. This should then return the profile information for the user you selected.

    I hope this helps!

    Scott

  • Hi there, I have created an infopath form using the contact selector and everything works fine when I use in Infopath, however when I try to fill out the form in the browser my form freezes. If I wait I can add a person to the Contact Selector, then I try to add one to the second contact selector and it freezes again.  It is obviously then the contact selector which is making it freeze.  Any ideas? Many thanks

  • Hi Emily,

    To the best of my knowledge, I have not seen this behvior before. A couple if things to look at:

    - Are you on the latest Service Packs for Office/InfoPath and for Microsoft Office SharePoint Server?

    - Are you using the latest version of Internet Explorer?

    - Try enabling "Verbose" logging on the server for the "All" category, reproduce the issue and then check the latest log to see if there are any errors getting logged when you try this process

    - You may want to look at using the "Fiddler" network tracing tool to see if you can see what call it is hanging on

    - As a last resort, if you are unable to isolate the cause, you may want to open a support ticket with the InfoPath team to allow them to see the behavior, capture some trace logs, etc.

    Scott

  • Hi Scott

    Here's the scoop.

    I have a custom Word Template that contains a custom DIP. That DIP contains

    two contact selectors. They work fine and as expected, however, every once in a while (2 - 7) entries of new documents created by the template crashes Word.

    I've narrowed it down to the contact selector. It will post a message that

    it is accessing the web service and then Word crashes with this error message: faulting module contactpicker.dll

    The DIP is not connected to a SharePoint list and is used only to populate content fields in the template.

    This has got me stumped. Fiddler tells me that the XML is coming back from the webService so I'm sure it's not connectivity. I just can't trap an event to tell me why contact selector has failed.

    Any thoughts would be much appreciated.

    Michael.

  • I follwed your instructions to the T, the only confusion I encontered is while creating the Context.xml,  in the XML Context the Servername can it be the actual Exchange server url or has to be the SharePoint site url where the infopath form resides?

    I inserted the SharePoint site URL in quotes ....

    <Context siteUrl="http://paportal.swmed.org"/>  but when I do the search it is failing.  Gives me Search Failed.

    Any suggestions?

    Thanks!

    RMall

  • I am new to infopath.  I followed the instructions but upon testing the form, when I do a search for a person I get Search failed.

    I am pointing my Context xml url to my SharePoint main site.  Do I need to point to the SharePoint site that contains the infopath form?  OR can I point to the Exchange Server?

    Any Suggestions?

    Thanks!

    NH

  • I am new to infopath and I followed the instructions.  But when I do a search for the person I get Search Failed.

    I am pointing to my SharePoint site in the Context xml i.e.

     <Context siteUrl="http://paportal.swmed.org" />

    Any suggestions why am I getting Search Failed?

    I have a SharePoint Farm with a Main Site and the form is loaded on a Subsite.

    Thanks

    RMall

  • RMall and NH:

    You should enter a URL to the SharePoint site where the InfoPath form will be used...it cannot be an Exchange Server. Now, with that said, the Context XML file is only used when the form is opened in the InfoPath client. If you are using these forms in the browser then it simply uses the site where it is published.

    So with that said, I am going to assume you are using these forms in the browser...if so, what happens if you perform a search for the same user but in a SharePoint screen (i.e. when you need to add permissions for a user) - does it fail there as well or does that work?

    Scott

  • Michael,

    Sorry for the delay...I have not seen an issue like this nor can I reproduce it in the tests I have tried. If you start fresh and have a consistent repro then I would suggest opening a case with the InfoPath Support team so we can take a look at this in greater detail.

    Scott

  • Hi Scott, the control change event is not functional in browser enabled forms. is this a bug for 2010? thanks

  • Hi,

    Regarding the changed event in the Contact Selector control - it appears you are using InfoPath 2010 to create an InfoPath 2007 compatible form template. If this is the case, then yes - the changed event is not available. However, if you create an InfoPath 2010 XSN, then it will be available.

    If you are indeed using InfoPath 2010 to create an InfoPath 2007 compatible XSN, I did try these steps and they appear to work:

    - Change the Compatibility to one of the 2010 formats

    - Add the Changed event and your code

    - Test to make sure it works as you need

    - Save

    - Change the compatibility back to 2007

    Scott

  • First time it worked for me. I removed the AccountType from it and then search failed. I tried doing it again it failed. I created a new solution and still it does not work. I am going nuts now

  • Hi Sambit,

    I am not sure I follow: why would you remove the "AccountType? Can you provide more details on what you are doing exactly to execute a search? Is this from the InfoPath client or from a browser form? InfoPath/SharePoint 2007 or 2010?

    Thanks,

    Scott

Page 25 of 27 (398 items) «2324252627