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:

  1. Insert the control onto the form, and design the appearance of the control as you want.

  2. Configure the schema of the control. To data-bind the control, you must create a data structure to store the selected contacts.

  3. 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

  1. 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).

  2. 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.

  3. 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

  1. In Office InfoPath 2007, insert the Contact Selector control into your form, as described earlier.

  2. Select the Contact Selector control, and in the Design Tasks pane, click Data Source.

  3. Click the arrow next to the Contact Selector name, and on the drop-down menu, click Add.

  4. In the Add Field or Group dialog box, create a group with the following properties:

    1. For Name, type Person.

    2. For Type, select Group.

    3. Select Repeating.

    4. Click OK.

  5. Click the Person group, and then on the drop-down menu, click Add.

  6. Add a field with the following properties:

    1. For Name, type DisplayName.

    2. For Type, select Field (element).

    3. For DataType, select Text (string).

    4. Select Repeating.

    5. Click OK.

  7. Click the Person group, and then add two more fields as described in the previous step.

    1. For Name, type AccountId for the first field, and AccountType for the second field.

    2. For Type, select Field (element) for each field.

    3. For DataType, select Text (string) for each field.

    4. 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

  1. 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.

  2. Save the file to your computer.

  3. Add the workflow context schema to your form as a secondary data source.

    1. In Office InfoPath 2007, on the Design Tasks pane, select Data Source, and then click Manage Data Connection.

    2. In the Data Connections dialog box, click Add.

    3. In the Data Connection Wizard, select Create a new connection to, and then select Receive data. Click Next.

    4. Select XML Document, and then click Next.

    5. Browse to the location where you saved your Context.xml file, select it, click Open, and then click Next.

    6. Select Include the data as a resource file in the form template, and then click Next.

    7. 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 Contact Data in Workflow Initiation and Modification Forms in SharePoint Server 2010 (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)

Other Resources

How to: Access Contact Data in Workflow Edit Task Forms