How to: Design a Workflow Task Form to Use Task Data in SharePoint Server 2010 (ECM)
Applies to: SharePoint Server 2010
When Microsoft SharePoint Server 2010 displays a custom Microsoft Office InfoPath 2007 form for a workflow task, SharePoint Server 2010 passes the task data to the form as XML. For your InfoPath task form to be able to understand and parse the task data XML, you must add the task schema to the form as a secondary data source.
To do this, you must create a file called ItemMetadata.xml that represents the task schema, and then add that file to your form as a secondary data source. Then you can data-bind your form controls to specific elements of the task schema XML.
Note
SharePoint Server 2010 always sends the task data XML to the task edit form on load. Because of this, you must always add an ItemMetadata.xml file to your form as a secondary data source, even if you do not plan on using any of the task data. Otherwise, SharePoint Server 2010 generates an error.
To create a schema file for a workflow task schema
In the text editor of your choice, create a file named ItemMetadata.xml.
Note
The file name ItemMetadata.xml is case-sensitive.
Add the following element to the file:
<z:row xmlns:z="#RowsetSchema"/>
In the file, define each task property that you want to use in your form. To do this, add an attribute composed of the prefix ows and the name of the task field. Set the attribute equal to an empty string.
For example, suppose there are two task fields you want to use in your form: instructions, and comments. Your finished ItemMetadata.xml file would contain the following:
<z:row xmlns:z="#RowsetSchema" ows_instructions="" ows_comments="" />
Note
You must define an ows attribute for each task field in your form from which you want to retrieve data, even standard task fields that are included on all tasks, such as Title or Assigned To.
You do not need to define attributes for any task fields in your form from which you do not want to retrieve data.
- Save the finished ItemMetadata.xml file to your hard disk.
To add the task schema to a workflow form as a secondary data source
In Microsoft InfoPath 2010, under Design Tasks, select Data Source, and then click Manage Data Connection.
On the Data Connections dialog box, click Add.
In the Data Connection Wizard, select Add a new connection to, and Receive data. Click Next.
Select XML Document. Browse to the location where you saved your ItemMetadata.xml file, select it, and then click Next.
Select Include the data as a resource file in the form template, and then click OK.
Enter ItemMetadata as the data connection name, and make sure Automatically retrieve data when form is opened is selected. Click Finish.
After you include the ItemMetadata.xml file as a resource file in the form template, you no longer need the ItemMetadata.xml file itself. You do not need to include the file in your workflow solution.
To data-bind your form controls to the task schema
In InfoPath 2010, double-click the control on your form that you want to data-bind.
In the Propertiesdialog box, on the Datatab, under Default Value, click the formula button.
In the Insert Formula dialog box, click Insert a Field or Group.
In the Select a Field or Groupdialog box, select your ItemMetadata data connection, and then select the field in that data connection to which you want to data-bind your control. Click OK.
In the Insert Formuladialog box, click OK. In the Properties dialog box, click OK.
For more information about data-binding form controls to data sources, see the InfoPath 2010 help.
See Also
Tasks
How to: Design InfoPath Workflow Forms (ECM)
How to: Access Workflow Task Form Data in a Workflow in SharePoint Server 2010 (ECM)
Concepts
InfoPath Forms for Workflows (ECM)
Workflow Association and Initialization Forms in SharePoint Server 2010 (ECM)