Workflow Task Forms (Windows SharePoint Services)

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

You can specify custom forms for the tasks in your workflow. Because tasks are SharePoint items that are assigned a content type, however, the content type determines the custom forms used with the task type.

Workflow Task Content Types

By default, all SharePoint task types are assigned content types. If you do not specifically assign a content type to a task type, the task type is assigned the Task base content type. All task-type content types must be based on the WorkflowTask base content type.

For more information about base content types, see Base Content Type Hierarchy.

You can specify custom new, edit, and display forms for a content type. Windows SharePoint Services uses any custom forms you have specified for the appropriate task content type when displaying a workflow task.

Note

For ease of programming, we strongly recommend that developers create content types for their task types, and that each task content type schema exactly match the schema of its designated edit task form. This approach provides one-to-one mapping of properties, and eliminates the need to parse the extended properties field to extract additional values.

Specifying Workflow Task Content Types

You can specify the content type for a workflow task in one of two ways.

To use a single content type for all your workflow task types

  1. In the content type definition of the task's content type, add an XMLDocument element that specifies the custom edit and/or display forms, if you want. This XMLDocument element must adhere to the FormTemplates schema. Set the edit and/or display forms to the following value:

    <Edit>WkTaskIP.aspx</Edit>
    <Display>WkTaskIP.aspx</Display>
    

    For more information on specifying custom forms for content types, see FormUrls Schema Overview.

  2. In the workflow template definition, set the TaskListContentTypeId of the Workflow element to the ID of the content type you want to assign to all your workflow task types. For example:

    TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"  
    

To use different content types for each workflow task type

  1. In the content type definition of the task's content type, add an XMLDocument element that specifies the custom edit and/or display forms, if you want. This XMLDocument element must adhere to the FormTemplates schema. Set the edit and/or display forms to the following value:

    <Edit>WkTaskIP.aspx</Edit>
    <Display>WkTaskIP.aspx</Display>
    

    For more information about specifying custom forms for content types, see FormUrls Schema Overview.

  2. Use the CreateTaskWithContentType workflow activity to create the task in your workflow. Use the TaskId property to set the task ID, and the ContentTypeId property to specify the task's content type.

Workflow Task Types

To differentiate the task types 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.

When a user clicks the link to edit a task, Windows SharePoint Services examines the workflow template definition to determine the task content type. It then examines the content type definition to determine whether a custom edit form is specified for this content type. If so, Windows SharePoint Services displays the specified form. If no custom edit form is specified, Windows SharePoint Services displays its default rendering of the edit form.

For more information about content type definition, see Content Type Definition Schema.

Types of Custom Content Type Forms

You can specify two kinds of custom forms for content types:

  • Form templates, which are .asmx controls that render the central section of a SharePoint Web page—everything but the SharePoint frame elements (usually termed the "chrome") on the page. Windows SharePoint Services renders the chrome for the page.

    For more information, see FormTemplates Schema Overview.

  • Form pages, which are .aspx pages that replace the entire default SharePoint page, including the SharePoint framing elements—the SharePoint "chrome." For form pages, you must provide any navigational links or other elements you want that are usually found in the SharePoint chrome.

    For more information, see FormUrls Schema Overview.

Workflow Task Form Processing

When a user clicks the link to edit a task, Windows SharePoint Services must determine the task type content type. If the task was generated by using the CreateTaskWithContentType workflow activity, the content type is specified in that activity. If not, Windows SharePoint Services examines the workflow template definition to determine the task content type.

Windows SharePoint Services then examines the content type definition to determine whether a custom edit form is specified for this content type. If so, Windows SharePoint Services displays the specified form.

The workflow developer is responsible for the data that is passed initially to the task form, and for what actions happen when the user submits the form. For example, the developer could program the form to retrieve the contents of the Xml property of the SPListItem that represents the task, and use that information as a data source. Windows SharePoint Services always passes the task XML to the form as a secondary data source.

Similarly, when the form is submitted, we recommend that the form call the AlterTask method, passing the SPListItem object and the updated data as parameters. Windows SharePoint Services raises an OnTaskChanged event when this method is called. To handle this event, add an OnTaskChanged event activity to the workflow.

See Also

Concepts

Workflow Forms Overview

Workflow Association and Initiation Forms (Windows SharePoint Services)

Workflow Modification Forms (Windows SharePoint Services)