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 2 and 1 and type the answer here:
  • Post
  • In part one I created an InfoPath form that employees could use to create a work schedule. Now I&#39;m

  • Contact Selector works as described.  Excellent.  

    I have one issue: I need to be able to retrieved disabled AD accounts.  We have field workers that do not frequently login, the accounts become disabled based on our security policy.  Their Supervisors need to fill out forms on their behalf.  The disabled accounts do get imported into SharePoint User Profiles database.  Any thoughs?

  • Hi rjburke,

    You will probably be better served posting that question to a SharePoint Newsgroup.

    Scott

  • Hello Scott,

    I have a problem using the contact selector control in DIP for a content type. The contact selector works fine when the DIP is generated from scratch using sharepoint content type management UI, but it doesn't work when the DIP is modified from parent content type DIP.

    In my scenario I have a tree of content types going from very generic ones to very specific ones. Since the generic (parent) content type already contains some code and external data connections, I do not want to recreate the DIP for each child content type from scratch, but instead I just want to modify the parent content type DIP.

    Unfortunately, if the child content type contains a new field of user/group type and I follow instructions in your article to add the contact selector control, I can select a specified user but the value doesn't bind. I think that the problem lies in the fact that the top level node is called UserInfo instead of Person. When the DIP is created from the scratch there must be some internal plumbing going on which resolves this issue.

  • Hi dtrodler,

    Correct - that repeating node must be called Person in order for this to work correctly.

    Scott

  • Hello Scott,

    thanks for the prompt reply. Is there any workaround? The DIP schema is read-only and I cannot rename that node.

    I think that reusing DIP from parent content type in child content types is quite common scenario and it would be nice to know how to use the contact selector in this case.

    Can you give me some information how it is done when the DIP is generated from scratch in sharepoint UI? The contact selector works in this case even when the repeating node is called UserInfo . I guess that some modification of the DIP form source files would help. Is there any documentation on this?

    Daniel

  • Hello Scott,

    When I type in a keyword and click Go I get: Search Failed. I have my Context.xml file pointing to my sharepoint site. We are currently using Microsoft Windows SharePoint Services 2.0 with InfoPath 2007. Any Ideas?

    Thanks!

  • Hello Scott,

    I think I have found a workaround for the "non-binding contact selector in derived DIP" problem.

    1.  Create content type A and generate its DIP using sharepoint UI (click "create new custom template")

    2. Modify the DIP as desired by adding external data connections, code etc..

    3. Create content type B which derives from A and has an additional field of type user

    4. Create its DIP by modifying A content type DIP (in sharepoint UI click "edit this template" instead of "create new custom template")

    5. In Infopath designer select "Convert Main Data Source" to update the schema to match the B content type

    6. Place the contact selector control on the form and bind it to your user field. (to the group node above the repeating UserInfo node)

    7. Save the B DIP form source files to "BDIPfromParent" folder

    8. Go to sharepoint UI and generate DIP for content type B again, this time from scratch (by clicking "create new custom template") - this will generate DIP with working contact selector control (but unfortunately all A content type DIP design is lost)

    9. Save the source files of this DIP form to "BDIPfromScratch" folder

    10. Open the file view2.xsl which is the stylesheet for the document management fields from the BDIPfromScratch folder and locate the contact selector control node (clsid:61e40d31-993d-4777-8fa0-19ca59b6d0bb)

    11. Copy the entire param section of this node

    12. Open the view2.xsl file from the  BDIPfromParent folder and located the contact selector control

    13. Replace the param section with the copied section.

    14. Make sure that the namespace prefix used in individual parameters corresponds to the same namespace as in the BDIPfromScratch view2.xsl

    15 Open the resulting form (by opening the manifest file in infopath) and publish it as a DIP for the B content type - you should have a working contact selector with your parent content type DIP design preserved!

    Daniel

  • Hi Daniel,

    Glad you were able to get a workaround!

    Scott

  • Hello Scott,

    I sent a message yesterday. Here's more information. We are in the process of upgrading to SharePoint 2007. We are currently using SharePoint Services 2.0. Followed the information above to build the contact selector control but It's not making a data connection. The error I get is "Search Failed". I have administrator access to the site. I've tried it on a blank template, with the same results. Will this work with SharePoint Services 2.0 or do I need to wait until we upgrade? As a rookie the team blog has be very helpful!

    Thanks,

    Mike

  • Hi Mike,

    To be honest, I think this is new functionality to 3.0. I don't have a 2.0 server to test at the moment...do you have the Contact Selector (may be called the People Picker) control in 2.0?

    Scott

  • Hi Scott,

    Thanks for the reply. We are using InfoPath 2007. I was able to set up the Contact Selector Control, but it doesn't look like the custom data connection using context.xml file is working. In SharePoint 2.0 I don't see a people picker control. Although, I can create a lookup field that pulls user information using the built-in functions. I have a SharePoint 3.0 server setup in the lab I'll see if it works there...

    Thanks,

    Mike

  • I've followed all the steps listed and the contact selector just displays Search Failed each time.  What else could I be doing wrong?

    Are there any reasons known why the search would fail?

    Thanks,

    Liz

  • Hi Liz,

    Where does it show the Search Failed? Also - you will want to make sure this works directly from SharePoint. Try these steps:

    - Create a new document library for Word

    - Add a new column to this library as a Person or Group column

    - Create a new document by clicking the New button and just save this to the library

    - Select the saved document and from the dropdown choose Edit Properties

    - You should now see the Person column you created - perform the same search you did using the Contact Selector control...what is the result?

    If it is still Search Failed then this is an issue with SharePoint and I don't have enough knowledge in SharePoint to troubleshoot that issue.

    If it works - then did you specify the correct site URL in the Context.xml file?

    Scott

  • I'm getting the same error as anca_accenture.  I have an infopath form serving as a workflow modification form.  When I try to enter anything on the people picker, it pops up with "There has been an error while processing the form."  Checking the logs, it has "Exception Message: 'my' is an undeclared namespace. Line 1, position 2."

    This form is also the association and initiation form.  It works normally in both those cases.  It is only as a modification form that it causes this error.  Any ideas?

Page 7 of 27 (398 items) «56789»