Workflow Task Forms (Office SharePoint Server 2007)
You can specify custom forms for the tasks in your workflow. Because a workflow task is a SharePoint item that is assigned a content type, the content type determines the custom forms to use for the task types in your workflow.
For more conceptual information about workflow task edit forms, see Workflow Task Forms (Windows SharePoint Services) in the Windows SharePoint Services 3.0 SDK.
Specifying Workflow Task Forms
To specify a Microsoft Office InfoPath 2007 edit form for a workflow task, do the following:
In the workflow definition file, set the TaskListContentTypeId attribute of the Workflow element to the following content type:
TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
This content type, included in Office SharePoint Server 2007, specifies custom task display and edit forms that include an Office Forms Server control for rendering InfoPath forms.
Add an element to the Metadata element of the workflow template definition. This element is TaskID_FormURN Element (Workflow), where N represents the integer you assigned to that task type within the workflow. Set this element to the URN of the Office InfoPath 2007 form you want to use with this task. For example:
<MetaData> … <Task0_FormURN>urn:schemas-adventureworks-com:workflow:ReviewRouting-Review</Task0_FormURN> … </MetaData>
To differentiate the task types that your workflow creates, you assign each task type an integer identifier within that workflow. The first task type is 0, the second 1, and so on. This enables you to assign different content types, and different forms, to each task type. These task type identifiers must be unique only within a given workflow. For example, any workflow that creates a task has a task 0 task type; however, the task type does not have to be the same across all workflows.
For more information about the Workflow Definition Schema, see Workflow Definition Schema in the Windows SharePoint Services 3.0 SDK.
Workflow Task Form Processing
When a user clicks the link to edit or display a workflow task, Office SharePoint Server 2007 examines the TaskListContentTypeId attribute of the Workflow element to determine the task content type. It next examines the content type definition to determine if a custom form is specified. If you are using an InfoPath edit form for your workflow task, you have set the content type to a type that specifies custom task display and an edit form that includes an Office Forms Server control for rendering the InfoPath form. Office SharePoint Server 2007 loads this custom form, which in turns examines the appropriate TaskID_FormURN Element (Workflow) element, based on the task ID Office SharePoint Server 2007 passes to it. The custom page then loads the specified form for the task types.
This page also retrieves the contents of the XML property of the SPListItem object that represents the task, and passes it to the form as a secondary data source.
When the user submits their changes to the form, the hosting page calls the AlterTask method, passing the SPListItem object and the updated data as parameters. This method updates the specified SPListItem object with the specified XML.
Office SharePoint Server 2007 processes the XML passed in the AlterTask method, passing the SPItem method in the following way: If a named property in the XML matches a property in the SPWorkflowTask object, Office SharePoint Server 2007 promotes the XML property value into the matching object property. Any XML properties that do not match properties of the SPWorkflowTask object are concatenated and stored in a "spill over" field on the object. You can use the GetExtendedPropertiesAsHashtable methods to access this data.
For ease of programming, we strongly recommend that developers create content types for their task types, and that each task content type schema match the schema of its designated edit task form exactly. This approach provides one-to-one mapping of properties, and eliminates the need to parse the "spill over" field to extract additional values.
Office SharePoint Server 2007 raises an OnTaskChanged event when the AlterTask method is called. To handle this event, add an OnTaskChanged event activity to the workflow. The AfterProperties property of this event contains the task properties that were changed.
See Also
Tasks
How to: Design an InfoPath Form for a Workflow in Office SharePoint Server 2007
How to: Access Workflow Task Form Data in a Workflow
How to: Design a Workflow Task Form to Use Task Data
Concepts
Workflows in Office SharePoint Server 2007
InfoPath Forms for Workflows
Workflow Association and Initialization Forms (Office SharePoint Server 2007)
Workflow Modification Forms (Office SharePoint Server 2007)
Workflow Task Forms (Office SharePoint Server 2007)