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

    Unfortunately I don't know what would be causing this behavior. I never tested these steps with workflow forms so you may want to post this question to a workflow forum or contact Product Support (for Office Workflow) for assistance.

    Scott

  • Hello, I am Ara.

    I am trying to use the contact Selector AcitveX control on browser enabled Infopath form.

    I followed your steps, and pulished it to a form library on MOSS2007 wich "Enable this form to be filled out by using a browser" cheked. The I can't open the form from the form library on SharePoint. Error says "Unknow error".

    Do you have any tips???

    Please help me.

  • Hi Ara,

    Are you able to successfully publish an InfoPath Form Template with, say, just a text box and open it in the browser? I would not think this is being caused by the Contact Selector control.

    Scott

  • Hello Scott,

    Yes, I can publish this form to form library successfully. And if I delete the contact selector control, I can open my form from sharepoint.

    Thank you for your help.

    Ara

  • Hi Ara,

    Have you followed the steps in this post exactly or are you creating your XSN from an external source (i.e. a schema file, database, etc.)?

    Not that it should not work but I have not experienced this issue when following the steps in this post.

    If you have indeed followed these exactly, please reproduce the error again and take a look at the SharePoint ULS logs to see if there is anything in there regarding the loading of your form. (NOTE: You may need to enable "Verbose logging" for the various Forms Services categories.)

    Scott

  • Hi Scott,

    You folks really seem to have a great handle on InfoPath, Great example!

    I have a couple of questions on a similar topic.  And if you could find your way to answering, it would be appreciated:

    Background: Infopath 2007 (Browser enabled), Main Data + 2 Sharepoint Lists as secondary data connections, Submitted to Sharepoint 2007 Forms Library and Email

    1. I  have a DropDown List Box that is bound to one of the secondary SP List connections returning CoNames (approx 1600 in list).  This was used since I have not been able to find a search function that returns only a subset of the list names.  The list names are resolved rhatehr quickly and I can see all 1600 names in the drop-down.  However, once I select a name from the list Explorer usually gives a message that the "A script on this page is causing Internet Explorer to run slowly."  I am guessing that the large number of data is causing this message to appear.  I have checked off "never" on the Post back settings but it does not seem to have helped at all.  Additionally, once I have chosen a CoName several other text boxes are then assoriated to the CoName record, i.e., CoEmail etc..  And, as I tab across other fields I continue to get the same pop-up concernign the script activity.

    So, the questions for this:  a) Are there any other methods to serch a SP field (using wild cards) would be extreemly helpful. b) Is there a way to speed up the forms lookup process so that we do not get the pop-up displayed?

    2.  Once the form is filled out by the sending company with the above information it is then to be sent to the receiving company by email in order for them to continue filling out the remainder of the form.  So, I need to permanently "paste" the information retreived from the SP list into the form so that the receiving company cannot change it.  But the receiving company will fill out other parts of the form that relate to their activity on the topic.  Note that the receiving company is not to have access to the SP list but only the form.

    The questions here are: a) The form currently attached to the email curently requires UserName and Password to continue filling out the form.  Since, apparently the sencondary data connections are still active once the email is received by the receivign company.  Is there a way to "paste" the chosen company specifics so that the form does not need to be connected to the DB?

    b) Is ther a way to enable the form to be filled out by companies not using Outlook 2007?

    I know these are not simple questions.  But the real world applications are also not usually simple.  Any help would be appreciated.

    Thank You,

    Gus

  • Hi Gus,

    In the future, please keep questions and comments specific to the post.

    1A: You would need to either write code behind InfoPath so you can send a custom CAML query or you can create a custom web service that uses a CAML query to return what you need - this way you don't need code behind InfoPath.

    1B: Don't return this many records - see 1A! :)

    2A: Make sure your data connections are not set to get the data when the form loads or you can look at caching the results for offline use. (Tools - Form Options - Offline.)

    2B: No - unless you use a browser form - then they would need access to the site where you are hosting the form.

    Like you have said, these are really not simple questions but I have provided "simple" answers. In reality, these will probably be more involved. You may want to poke around the InfoPath Newsgroups and see what others are doing or create a support incident where you can review this with an InfoPath Support Engineer.

    Scott

  • Hi Scott,

    Thanks for the reply..  I am sorry for posting here, but it looked (at least to me) like similar topic.  Anyway, in the future I will try to find a closer fit.

    Thanks Again,

    Gus

  • does this ContactSelector activex works on browser-enabled InfoPath form?

    Thanks,

    John

  • Hi John,

    Yes - what you will probably have to do is set the Comptibility of your XSN to just InfoPath, add the Contact Selector control and then reset the Compatibility back to InfoPath and Forms Services.

    Scott

  • Hi Scott,

    I am having a couple of problems.

    I followed every detail and when I tried searching for name it would pull up the names relevent to the search but then after selecting it the selector just goes inactive/blank.

    When I tried entering a name and checking it... it just goes inactive/blank.

    I started over, step by step, and noticed Step 3 "Drag the gpContactSelector Group to the View and select “Contact Selector” from the list of controls". When I try that there is no option for selecting the Contact Selector.

    I am trying to set up a form that will be used as you stated "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." So after the Supervisor is selected a email or task can be assigned.

    I am further hoping that the content of the selector can be referenced to assign a user role to grant access to conditional controls. And to send the user to a column in a SharePoint.

    Your help will be much appreciated.

    Best Regards,

    Jason

  • Plus on Step 4 of Step 4 it says "

    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

    I do not see this option. There is however an "Automatically retrieve data when form is open" Option and you can select resource files and browse to the Context.xml file to include it in the template on the first screen for adding a Data Connection.

    V/R,

    Jason

  • Hi Jason,

    The first thing I would suggest you verify is that the spelling/capitalization is correct in the data source for the Contact Selector control.

    Also - make sure the URL you reference in the XML file is valid for your site.

    Regarding your reference to step #4 - the steps you describe are correct: browse for the XML file and then make sure it gets included as a resource file.

    Scott

  • Hi Scott,

    I had the following wrong:

    AccountId was AccountID

    and the binding was set to Person instead of gpContactSelector

    The option to select the Contact Selector resolved itself when the above were fixed.

    I am still having a challenge getting the form to reference the user selected for a user role. I am trying the 3 different values: DisplayName, AccountId and AccountType. We'll see what happens... AccountId WORKED!

    Thanks... now all I need to do is figure out how to get the Army to give me a raise... lol!

  • Hi Jason,

    That is great to hear - congratulations!

    Scott

Page 8 of 27 (398 items) «678910»