Contact Selector in InfoPath 2007 and 2010

来源:互联网 发布:权威的时尚杂志 知乎 编辑:程序博客网 时间:2024/05/17 12:51

There are heaps of articles and blogs out there that describe how to create the Contact Selector control in InfoPath 2007. I guess I just want to take the opportunity to refresh everyone’s mind on this and also show you how to create the Contact Selector in InfoPath 2010 for an InfoPath 2007 form.

Let’s start with InfoPath 2007:

  1. Creating the control:
    1. In InfoPath select Insert -> More Controls
    2. A task pane comes up and on the very bottom you will have the option Add or Remove Custom Controls
    3. Select this option, Click Add in the next dialog box
    4. Select ActiveX Control and click Next
    5. Select Contact Selector from the list of controls and click Next
    6. Select Don’t Include a .cab file and click Next
    7. Select Value for the binding property and click Next
    8. Select Field or Group as the Field or Group Type and click Finish
    9. Click Close and then OK
  2. Creating the data structure: (Note: You have to ensure that spelling, structure and capitalisation is exactly as described in the next steps)
    1. Navigate to the Data Source pane in InfoPath
    2. Right click the node where you want the control’s data structure to sit within your form schema (e.g. right click “myFields”) and selectAdd

    3. Add a non-repeating group as shown below. (Note:
      the name of this group is up to you)

    4. Add a repeating group named Person as shown below

    5. Add 3 text fields to the repeating group, labelled DisplayName, AccountId, and AccountType

  3. Create a data source to specify the SharePoint server: (Note:this step is only applicable if you have client AND browser-based forms. If you have browser-only forms, the form will always run in the context of the site the form is published to)
    1. Open up a text editor of your choice (e.g. NotePad or WordPad)
    2. You can copy and paste the following:

      <Context siteUrl=”http://<YourServerName>”/>

    3. Save the file as Context.xml
      DO NOT SAVE IT AS A TEXT FILE
    4. Return to InfoPath and select Tools -> Data Connections

    5. Click Add
    6. Select “Create a new connection to” and then “Receive data
    7. Select XML document and click Next
    8. Browse to the Context.xml file you created earlier and select it, then clickNext
    9. Leave the default option selected and click Next
    10. Make sure “Automatically retrieve data when form is opened” is selected and clickFinish
  4. Add the Contact Selector to the form:
    1. Click on the myContactSelector group and simply drag & drop it onto the form
    2. The following selection comes up and you need to select Contact Selector

    3. Last but not least TEST YOUR FORM

Now let’s have a look at InfoPath 2010:

In InfoPath 2010 you have the Contact Selector as a ready-to go control already built in. There is no need to perform any configuration steps other than Step 3 from the instructions above. Again this only applies in case you deploy forms that will also be used on clients. Simply select the Person/Group Picker control from the controls list. InfoPath will automatically add the data structure required for the control.