How to: Design a Workflow Task Form to Use Task Data
When Microsoft Office SharePoint Server 2007 displays a custom Microsoft Office InfoPath 2007 form for a workflow task, Office SharePoint Server 2007 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.
Office SharePoint Server 2007 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, Office SharePoint Server 2007 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.
The file name ItemMetadata.xml is case-sensitive.
Add the following element to the file:
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="" />
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 Office InfoPath 2007, 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 Microsoft Office InfoPath 2007, double-click the control on your form that you want to data-bind.
In the Properties dialog box, on the Data tab, 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 Group dialog 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 Formula dialog box, click OK. In the Properties dialog box, click OK.
For more information about data-binding form controls to data sources, see the Office InfoPath 2007 help.
TasksHow to: Design an InfoPath Form for a Workflow in Office SharePoint Server 2007
How to: Access Workflow Task Form Data in a Workflow
ConceptsInfoPath Forms for Workflows
Workflow Association and Initialization Forms (Office SharePoint Server 2007)
Workflow Task Forms (Office SharePoint Server 2007)