(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:
**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 HeimSupport Engineer
Hi, Thanks for your post. This is really a helpful and useful post.
I have successfully added the control into my form following this article. It works fine in my pc (form development pc) but I have got 'search failed' message from other pc.
What should I do now?
A few questions:
- Is the other PC a client machine?
- Are you hitting the same site?
- Are you logged onto the other machine as the same account you used from your machine? If not, log onto that machine as yourself and make sure it still works.
- If it works for you and not the other user, does the other user have appropriate permissions? What happens if they just use Internet Explorer, browse to your site and try to do something that requires a search like this (i.e. add themselves to a group, etc.) - does it work directly in SharePoint?
You also may want to try getting a "Fiddler" trace (http://www.fiddler2.com) and see if this shows any failure that may help you isolate the problem.
Appreciate you sharing stories, are very like your article, hope can continue to post more interesting topics,Now is a fashionable society,[url=www.missbagsbeauty.com/.../fake-alexander-wang-644.html]cheap Alexander Wang handbags[/url] also share some interesting gifts.
Is there any additional trick to getting the contact selector control to work on a form that already has digital signature controls on it? When I add a contact selector to an InfoPath 2007 form that uses digital signature controls and configure the context, the lookups from the control don't seem to do anything. I'm wondering if there is contact selector logic in the digital signatures or something else that is conflicting with the contact selector I'm adding?
Sorry, that last post was based on an invalid assumption. It turns out that the digital signature isn't causing the problem afterall. I removed it and the problem persists. Clicking on the icon for lookup brings up a dialog and I can select the user from the AD, but it doesn't populate the visible field or allow any subsequent lookups. I'll check back to the previous responses to see if any of the other suggestions seem to help.
I've followed the instructions and was able to make it work, but for some reason when I tried again on a new form
it doesn't work. When I preview the form and select "to" I'm able to search the names from the active directory, but when transferred over to the form, the name won't generate and it control gets grayed out. Am I doing something wrong?
Typically the behavior you are seeing is because one or more of the fields for the contact selector is either not spelled correctly or is not capitalized correctly. Can you please check that the field names are identical to what is in the blog and have the same capitalization?
It still doesn't work and I rechecked over and over that it was correct. Any other tips?
If the context.xml file is pointing to the correct URL and you have verified the spelling and capitalization of the node names in the data source, then no...unfortunately I am out of ideas. These have been the only cases where I have seen the control get grayed out.
If you are unable to get this working then you may want to open a support case so the InfoPath team can look into this deeper for you.
i want to use the data to a workflow in designer
how can i seperate the users
when i try to reach the data, i get only the first user
I am assuming what you are referring to is the behavior you get when you "promote" the Contact Selector node to a column in SharePoint? If so, then try using the "merge" function - this should give you a concatenated result of the users you have selected in the control.
hi Scott, thanks for your blog. I'm from Brazil and I read your posts about InfoPath. I'll try to explain my problem, in english. My form is ok: the activex control searches my users, opening the window users from Sharepoint. But, when I select the user and click on button OK, the message appears: "There has been an error while processing the form". How this is possible?
The application brings all the users, but it cant put the data in my form.thanks a lot.!
Off hand, I don't know what would cause that error. What I would suggest is to enable "Verbose" logging on your server for the Forms Services categories, reproduce the error and then check the SharePoint ULS logs...hopefully there will be additional details in the logs that point you in the right direction.
Scott, 4 years after this was posted, this is the most helpful post for getting the contact in there!
So after getting the contact selector to work great on one form, I can't get it to work on a second form. :( When I enter my NT id and say search, it greys the box out. Any ideas?