How to: Configure a Contact Selector Control on Your InfoPath Workflow Form (ECM)
Applies to: SharePoint Server 2010
You can configure the Contact Selector control for use on a workflow form in three basic steps:
Insert the control onto the form, and design the appearance of the control as you want.
Configure the schema of the control. To data-bind the control, you must create a data structure to store the selected contacts.
Add workflow context data as a secondary data source. The form requires this workflow context to know which SharePoint site to validate the specified users against. The workflow context also includes information you can use in form rules based on how the form is being used in the workflow.
To add a Contact Selector control to an InfoPath 2007 form
In Microsoft Office InfoPath 2007, from the Controls pane, drag a Contact Selector control onto your form.
Note
The Contact Selector control is a custom ActiveX control, included in Microsoft Office SharePoint Server 2007. You must add it to the Controls pane to make it available for use in workflow forms. For more information, see How to: Add the Contact Selector to InfoPath (ECM).
Double-click the control. In the Contact Selector Properties dialog box, on the Data tab, for Field or group name, type a name for the control. Click OK.
Design the appearance of the control as you want.
For more information about designing the appearance of controls in Office InfoPath 2007, see the Office InfoPath 2007 developer documentation.
Configuring the Contact Selector Control Schema
To data-bind the Contract Selector control, you must create a data schema within the control that represents each contact. Create the schema for each contact in the following format.
<person>
<DisplayName>user display name</DisplayName>
<AccountId>DOMAIN/user account</AccountId>
<AccountType>user or group type</AccountType>
</person>
For example:
<person>
<DisplayName>Jane Doe</DisplayName>
<AccountId>REDMOND/janed</AccountId>
<AccountType>SPUser</AccountType>
</person>
Following are the elements of the schema:
person Root element of the schema that represents one contact.
DisplayName Display name of the contact in Windows SharePoint Services or Active Directory directory service.
AccountId Domain and user account identifier for this contact.
**AccountType ** Type of account that this contact represents.
To create this data schema in the control, you must add and configure a group called person that contains three fields, as described in the following procedure.
To configure the schema for a Contact Selector control
In Office InfoPath 2007, insert the Contact Selector control into your form, as described earlier.
Select the Contact Selector control, and in the Design Tasks pane, click Data Source.
Click the arrow next to the Contact Selector name, and on the drop-down menu, click Add.
In the Add Field or Group dialog box, create a group with the following properties:
For Name, type Person.
For Type, select Group.
Select Repeating.
Click OK.
Click the Person group, and then on the drop-down menu, click Add.
Add a field with the following properties:
For Name, type DisplayName.
For Type, select Field (element).
For DataType, select Text (string).
Select Repeating.
Click OK.
Click the Person group, and then add two more fields as described in the previous step.
For Name, type AccountId for the first field, and AccountType for the second field.
For Type, select Field (element) for each field.
For DataType, select Text (string) for each field.
Select Repeating for each field.
Adding Workflow Context Data as a Secondary Data Source
For the form to know which SharePoint site to validate the specified contacts against, you must add a workflow context schema to the form as a secondary data source. This context schema contains the URL of the specified SharePoint site. The schema also contains context information that you can use when programming rules and logic in the form. For example, the context information includes data you can use if you want to switch form views based on where in the workflow the form is used, or whether the form is opened on the server or a client computer.
When Windows SharePoint Services loads the form as part of a workflow, it populates the data in the workflow context schema for the form.
The schema is as follows.
<Context
isStartWorkflow="true"
isRunAtServer="false"
provideAllFields="true"
siteUrl=""
/>
Following are the elements of the schema:
Context Root element that represents the workflow context information being passed to the form. The Context element has the following attributes:
isStartWorkflow Boolean; true if the form is being used as the workflow initiation form. You can use a specified form as both workflow association and initiation form, and it can present different views at each stage.
isRunAtServer Boolean; true if the form is being opened on the server.
provideAllFields Boolean; true if the form is being used as the last point of user interaction before the workflow starts. This means the form is being used either as a workflow initiation form or as a workflow association form for a workflow you have specified to start automatically.
**siteUrl **String. The URL of the SharePoint site from which the form is being opened.
To add the workflow context data to the form, you must first create an XML file that represents the context schema, and then import that file into the form as a secondary data source.
To add workflow context data to the form as a secondary data source
In the XML editor of your choice, create an XML file named Context.xml. This file represents the workflow context schema. Include one node, Context, with the following attributes.
<Context isStartWorkflow="true" isRunAtServer="false" provideAllFields="true" siteUrl="" />
Note
The form does not use the actual values specified in the first three attributes; they are included solely to indicate that the attributes are defined as Boolean data types.
Save the file to your computer.
Add the workflow context schema to your form as a secondary data source.
In Office InfoPath 2007, on the Design Tasks pane, select Data Source, and then click Manage Data Connection.
In the Data Connections dialog box, click Add.
In the Data Connection Wizard, select Create a new connection to, and then select Receive data. Click Next.
Select XML Document, and then click Next.
Browse to the location where you saved your Context.xml file, select it, click Open, and then click Next.
Select Include the data as a resource file in the form template, and then click Next.
Type Context as the data connection name, and ensure that Automatically retrieve data when form is opened is selected. Click Finish, and then click Close.
After you include the Context.xml file as a resource file in the form template, you no longer need the file. You do not need to include the file in your workflow solution.
Note
Context.xml is required as a secondary data source for workflow forms. Without the data it provides, the Contact Selector control cannot determine which SharePoint site to validate the entered contacts against. If you do not add Context.xml as a secondary data source, the form generates an error when it opens.
See Also
Tasks
How to: Design InfoPath Workflow Forms (ECM)
How to: Add the Contact Selector to InfoPath (ECM)
How to: Access Association and Initiation Form Data in a Workflow in SharePoint Server 2010 (ECM)
Concepts
InfoPath Forms for Workflows (ECM)
Using the Contact Selector Control in InfoPath Workflow Forms (ECM)