Step 2: Create the Workflow Task Edit Form in SharePoint Server 2010 (ECM)

Last modified: June 24, 2011

Applies to: SharePoint Server 2010

In this step, you create a form that enables workflow users to interact with the workflow task that is assigned to them.

This step in the walkthrough follows procedures that are described in How to: Design a Workflow Task Form to Use Task Data in SharePoint Server 2010 (ECM).

Note Note

This procedure assumes that you are familiar with adding controls to a Microsoft InfoPath 2010 form and configuring those controls.

To create the workflow task edit form

  1. Open InfoPath Designer 2010.

  2. In the Popular Form Templates section, select Blank Form, and then click Design Form.

  3. Add the following controls to your form:

    Control Type


    Data Type

    Text Box


    Text (string)

    Check Box


    True/False (Boolean)




    When you are finished, your form should resemble the following figure.

    Workflow task edit form
  4. Add rules to the OK button on your form:

    1. On your form, select the OK button.

    2. On the ribbon, click Add Rule. Point to When this button is clicked, and then click Submit Data.

    3. In the Rules dialog box, click Add.

    4. In the Rule Details dialog box, click Add to select a data connection.

    5. In the Data Connection Wizard, select Create a new connection to, select Submit data, and then click Next.

    6. Enter a name for the data connection, and then click Finish.

    7. Select the hosting environment option. Click Next.

    8. Again, select the OK button on your form, and click Add Rule. Point to When This Button Is Clicked, and then click Close Form to add another rule to close the form.

    9. Click OK to exit from the various dialog boxes.

  5. Create a schema file for your workflow task schema:

    Adding the workflow task schema to your form as a secondary data source enables SharePoint Server 2010 to provide the form with task data, which is used to prepopulate field values after the form is loaded. The first step is to create an XML schema file that represents your workflow task schema. For more information, see How to: Design a Workflow Task Form to Use Task Data in SharePoint Server 2010 (ECM).

    1. Using the text editor of your choice, or Microsoft Visual Studio, create a file named ItemMetadata.xml.

      Note Note

      The file name ItemMetadata.xml is case-sensitive.

    2. Add the following element to the file.

      <?xml version=”1.0” encoding=”utf-8”?><z:row xmlns:z="#RowsetSchema" 
    3. In the ItemMetadata.xml file, define each task property that you want to use as data in your form. To do this, add the prefix ows_ as an attribute, and also add the name of the task property. Set the attribute equal to an empty string.

      In this case, you want to display the instructions that the user entered in the initiation form. Remember that these instructions were added to the workflow task as extended properties when it was created.

      The following code demonstrates how to access the extended property from code.

      private void createTask(object sender, EventArgs e)
            taskProps.ExtendedProperties["instructions"] = instructions;

      For this reason, you must add an attribute for the instructions task property. Your completed ItemMetadata.xml file should contain the following text.

      <z:row xmlns:z="#RowsetSchema" 
    4. Save the finished ItemMetadata.xml file to your hard disk.

  6. Add the workflow task schema to your form as a secondary data source.

    1. In InfoPath 2010, on the Data tab, select Data Connections.

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

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

    4. Select XML Document, and then click Next.

    5. Browse to the location where you saved your ItemMetadata.xml file, select the file, and click Open. Click Next.

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

    7. Enter ItemMetadata.xml as the data connection name, and make sure that Automatically retrieve data when form is opened checkbox is selected. Click Finish, and then click Close.

      After you include the ItemMetadata.xml file as a resource file in the form template, you no longer need the file in your workflow solution.

      Note Note

      ItemMetadata.xml is required as a secondary data source for task forms. If you do not add ItemMetadata.xml as a secondary data source, the form generates an error when it opens.

  7. To let SharePoint 2010 know what columns your form fields will map to, data-bind the Instructions text box control to the instructions elements in the workflow task schema.

    1. Right-click the Instructions text box control, and select Text Box Properties.

    2. In the Text Box Properties dialog box, on the Data tab, under Default Value, click Formula.

    3. In the Insert Formula dialog box, click Insert a Field or Group.

    4. In the Select a Field or Group dialog box, select your ItemMetadata data connection that you created earlier.

    5. Select the ows_instructions element.

    6. Click OK. In the Insert Formula dialog box, click OK. In the Text Box Properties dialog box, click OK.

      The Instructions text box control is now bound to the instructions workflow task property. When SharePoint Server 2010 loads your task form, the form displays the task instructions in the text box.

    Notice that you used a Boolean value to add a check box named isFinished to the form. This now becomes an extended property of the workflow task, and it is passed to the workflow by SharePoint Server 2010. Remember, each time the user edits the task, the workflow code responds to the task change event, and uses this property to determine whether the task is complete.

    private void onTaskChanged(object sender, EventArgs e)
        notFinished = 
  8. Publish the form:

    1. In InfoPath Designer 2010, click File, and then click Save As. In the Save As dialog box, type TaskForm.xsn as the file name. Save the form to the location of your choice. You will browse to this location in future steps to add the file as a resource to the workflow project.

    2. Click File, click Publish, and then click SharePoint Server.

    3. In the Publishing Wizard, enter the location of your form library, name the file TaskForm, and then click Save.

    4. In the Publishing Wizard, enter form library URL where you want to save the form, and then click Next.

    5. Select the Form Library option, and then click Next.

    6. Choose whether you want to create a new forms library or use an existing one. Click Next.

    7. Map the fields in your form to the columns in the library you are publishing to, and click Next.

    8. Verify your form details, click Publish, and then click Close.