Using multiple Contact Selector controls in a single InfoPath form
I know what you’re thinking ….”Wooohooo … yet another article from Martin about InfoPath and the Contact Selector control!”. I know I’m sounding a bit like a broken record with this particular topic right now but there are lots of useful tips to share about this control and how to get the best of it.
If you are unsure what I mean by Contact Selector control it is a neat control that allows you to select users from a GAL-style interface within an InfoPath form:
These links provide useful reference for how to use the control
My own article: Top Tips for InfoPath form development with SharePoint: Part 1 (look for tip 4)
The InfoPath Team Blog: Using the Contact Selector Control
MSDN: The Contact Selector Control
In some types of form it may be necessary to have multiple instances of the Contact Selector control. For example an expenses form where you need a Contact Selector for the claimer's name and another for the approvers’ name.
One of the issues with the Contact Selector control is that it is not immediately obvious how you use multiple instances of it within the same form. This is because the control itself has to be bound to a very specific data structure and the naming of this data structure must be exact in order for you Contact Selector to work properly.
The way you achieve multiple instances of this is to built the data structure once and reference it to other parts of the form’s Data Source. You do this by following these steps:
1. Built the ‘source’ structure at the root of your form’s data source to look like the image below (naming, structure and capitalisation need to be exact!)
2. Create folders for each of the Contact Selector instances that your require. in our example this would be ‘Claimer’ and ‘Approver’
3. Reference the source structure to the folder you created in step 2. This is achieved by right-clicking gpContactSelector > Reference > Choose the folder you want to reference to
4. Add the Contact Selector controls to your form (from the Toolbox, if they do not shown up, read this article) and bind them to the referenced gpContactSelector folder beneath the folder that represents the field the form need to capture information for. For example the ‘claimer’ should be referenced to <root> / Claimer / gpContactSelector. Your final form should look like this (shown in Visual Studio 2008):
That is it, you are now done and both Contact Selector controls can independently store data in your form.
If you would like a copy of teh XSN for this article, please contact me using the details below.
This article was published by
Martin Kearn Senior Consultant Microsoft Consulting Services UK Martin.Kearn@Microsoft.com |
Comments
Anonymous
April 28, 2009
PingBack from http://asp-net-hosting.simplynetdev.com/using-multiple-contact-selector-controls-in-a-single-infopath-form/Anonymous
April 30, 2009
Top News Stories Office 2007 Service Pack Boosts Performance (Technologizer) Service Packs are usuallyAnonymous
May 05, 2009
Is there a way to limit the number of people selected to 1?Anonymous
May 10, 2009
In repsonse to Sharmalie's comment: yes there is a 'hacky' way to limit the number of contents in the control but it is not very nice and required a good understaidng of tehunderlying data structure. I may blog about it some time soon but basically involves addin a load of conditional formatting to the control (or you submit button) based on certians values in the contact selector. Even if you do so this, you cannot stop users entering multiple values, but you can stop them submitting the form if there are multiple values. Martin KearnAnonymous
May 27, 2009
Hi, Thanks for the tip! I am stumped at how I can get the values of the seperate contact selectors to populate alternate columns within the form library!? Any suggestions? RegardsAnonymous
June 03, 2009
Hello, I have a IP 2007 form(web) that I am publishing over SharePoint site running InfoPath form services. I followed the exact steps mentioned to create 2 groups for 2 contact selectors I need to embed into the form. It gives me error when I open the form from the form library. I also tried creating just 1 group without using the referencing concept, it works fine, but not with referencing in 1 group or 2. Can you help me out with what might I be missing or need to add. Any requirements/schema change on web based forms over SharePoint? I appreciate your talent and your posts.Anonymous
June 23, 2009
Hello all, This post is a great help but there's one thing to point out - I've found that it's important to ensure the Person group is a direct child of the group you create for each Contact Selector. i.e. If you create a group named 'Claimer' as in the given example, you must ensure that the reference is set on 'Person' not 'gpContactSelector'. Your element hierarchy should look something like this:
- Claimer
-
- Person
-
-
- DisplayName
-
-
-
- AccountId
-
-
-
- AccountType
-
Anonymous
August 07, 2009
The comment has been removedAnonymous
September 17, 2009
Thanks this post helped me a lotAnonymous
September 30, 2009
Hikmer is quite correct, though I might have phrased the critique more kindly! Both this post and the original source on the Infopath Team blog at http://blogs.msdn.com/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx#9575283 are propagating incorrect information, and Martin clearly didn't test this before taking screen shots and publishing.Anonymous
November 01, 2009
Thanks a lot martin for the post and also thanks Jason.Anonymous
November 01, 2009
Thank you Martin, this helped me a lot! Not rubbish at all, I got it working right away :-)Anonymous
November 02, 2009
AUTHOR FOLLOW-UP Responding to Jason Dunbar, Hikmer and Eric. Just looking through the comments and it seems like a few of you have had troubles with these steps - especially steps 3/4. I have just re-checked and the orginal steps are correct. In my scenario I DO bind the Contact Selectors to the referenced gpContactSelector (not person) and it works. In reference to Jason's comment, if you look at my screen shot you'll see that my person groups are beneath the referenced gpContactSelector group not the claimer / approver groups. Looking at the element structure you have posted, i suspect that you have manually created these, not referenced them because if they were reference (as the post advises) you would have to have the gpContactSelector node in there too? The key thing that people seem to be missing is that the nodes beneath claim and approver are REFERENCES of the source gpContactSelector node, they are NOT manually created. Please carefully re-read step 3. Please be assured that I always test this stuff before i blog it and on both occasions (when i orginally wrote the post ) and just now, the steps work. In terms of why this is not working for others, all i suggest is to try the folloinwg:
- ensure you are binding to the referenced gpContactSelector not the source one
- ensure that the nodes beneath claim and approver are reference not manually created nodes (that is the whole point of the article)
- ensure you have capitalistaion correct If anyone continues to have issues, please contact me on martin.kearn@microsoft.com and I'll do what i can to help you. Regards - Martin
Anonymous
November 02, 2009
Further to my repsonse above, if anyone wants a copy of the XSN for this artcle, please email me and I'll happy send it to you. Regards - MartinAnonymous
November 04, 2009
Hi, I have a question about the view columns in the document library I’ve published the form to. Is there a way to change the column headings for the contact selector columns? As it is now, they’re all showing as 'Display Name'. Regards /PetraAnonymous
November 04, 2009
Hi, Sorry, never mind my question above. I found a way of solving it. Regards /PetraAnonymous
November 09, 2009
Hi martin Abosolutlely Cowabunga maaan. Thank you. Just need to follow the instructions properly. And it wasnt roobish mate.Anonymous
January 28, 2010
Hey Petra, how did you change the column name?Anonymous
February 01, 2010
I have been having problems getting the contact selector to work with Office SP2. I am not able to bind a group to the Contact Selector. I tested this because I have one system with SP1 and one with SP2. It works great in SP1 but is broken in SP2. Anyone else seeing this? In addition, I had to bind to the group 1 level above Person (repeating field) to get this to work in InfoPath Form Services. DennisAnonymous
March 24, 2010
Using Form services. Everytime I test this with multiple selectors on the page IE crashes. As soon as I remove all but one of the selctors it works file. I followed all the instuctions, inlcuding binding to the gpContactSelector folders under the manually created folders.Anonymous
May 25, 2010
Martin, Thank you for the post. I was able to get multiple Contact Selector controls working on my form, but I could not see the user name when I preview the form. Any ideas? Thanks, RuiAnonymous
August 30, 2010
Setting the reference to 'Person', rather than 'gpContactSelector' worked for me.Anonymous
September 06, 2010
Thanks a lot Martin. The article was very useful to meAnonymous
October 06, 2010
I've been using the Active x Contact selector for some time without any issues. I have come across one anomaly that I can't seem to resolve. We have a form that is using the contact selector and is served up via Form Services. Our user profiles are synchronized from Active Directory. One of our users had their title changed. We verified that the user profile in MOSS reflects the correct information. Unfortunately, the pop-up that the contact selector presents, still reflects the old information. We've been able to test out changing another person's title and the contact selector eventually presents the new value. We have tried changing the user profile several times and even went as far as deleting the user profile and re-importing with no success? Does anyone know how or where this information is cached and how to resolve this?Anonymous
November 17, 2010
If any guy knows about the sharepoint infopath form data need to saved in the list with out using any code .Please help meAnonymous
March 13, 2011
Thank you Martin,that's greatAnonymous
May 18, 2011
Hi Martin, Multiple control selectors are causing Infopath form to load slowly. Is there any way, I can configure these control selectors to pick data from SharePoint group rather then AD. And will this solve the performance issue??Anonymous
July 26, 2011
Hello Martin, Thanks for the post, it helped me a lot.. Getting to the questions,
- What are the default fields used/displayed by the contact selector control. ?
- Can we get other attributes like Mailbox OU, Primary SMTP address ?
- Once I Select a user from the control , can i set other fields value with Mailbox Ou , Primary SMTPaddress ?. All Help appreciated. Thanks Naveen
- Anonymous
July 26, 2011
Adding to above post: My environment is Office/ Infopath 2007, Sharepoint 2007 Exchange 2007 hope this helps ...