Friday, March 17, 2017

Assign a to-do item in a workflow

Assign a to-do item in a workflow

When you design a workflow, you often want to assign work to a participant in the workflow. The simplest scenario is when you don't require any information from the participant — you just want to know that the work was completed so that the workflow can continue.

For example, you might want several participants to review a document and mark it up with their comments and proposed changes. But you don't need the workflow to collect their feedback or any other information; you simply want to know that the work was completed.

To-do task example diagram

To accomplish this, you add the Assign a To-do Item action to your workflow. The action assigns a task to each of the participants, prompting them to perform their individual reviews and then, when they are done, to click the Complete Task button on their task form. The task form produced by this action is a very simple one, having only a Complete Task button and a Cancel button, and no form fields to be completed.

This article shows you how to assign a to-do item to one or more workflow participants so that the workflow pauses until all of the participants complete the task.

In this article

Which action should I use to create this task?

What is a custom task form?

Assign a to-do item

Which action should I use to create this task?

Tasks are the primary way for a workflow to interact with participants in the workflow. If you want your workflow to require work from people or to get information from them, you can have the workflow create and assign a task. Each time a workflow assigns a task, the workflow pauses until that task is completed. The workflow resumes only when a participant clicks the Complete Task button on the task form.

There are three different actions that create a task, and each action is designed for a specific kind of situation:

  • Collect Data from a User     This action assigns a task to a single user or group and returns the unique ID of the task item that stores the user's answers, so that the workflow can later look up this information by using the ID. With this action, you use the Custom Task Wizard to design a custom task form that collects the information you want. This action creates a task that can be assigned only to a single user or group. If you assign this task to a group, each member of the group receives a task notification, but only one task item is created, and the workflow pauses only until the first person to respond completes the task. For more information about this action, see the article Collect data from a user in a workflow.

  • Assign a Form to a Group     This action assigns a form to one or more users, and then stores the responses as values in the Tasks list. Unlike the previous action, this action can assign a task separately to multiple people, and the workflow pauses until each person completes their task before it resumes. Also unlike the previous action, this action does not return the ID of the task item for any of the responses, so the workflow cannot look up and use that information later as the basis for making comparisons or decisions. With this action, you also use the Custom Task Wizard to create a custom task form. For more information, see the article Assign a form to a group in a workflow.

  • Assign a To-do Item     Unlike the other two task actions, this action creates a task form that has no form fields to fill out but instead uses a form where the user simply clicks a Complete Task button when the task is finished. This task can be assigned separately to multiple people, and the workflow pauses until each person marks their task as complete. This action does not return the ID of the task item — and doesn't really need to because the task does not collect any information that you might want to reference later.

The following table summarizes this information.

Action

Returns the task ID for workflow lookups?

Creates multiple tasks?

Enables you to define fields on the task form?

Collect Data from a User

Yes

No

Yes

Assign a Form to a Group

No

Yes

Yes

Assign a To-do Item

No

Yes

No

In addition, several limitations apply to all three task actions:

  • When a workflow assigns a task to a group that is identified by a single alias or address, the workflow creates only one task item, which is then shared by the entire group. Any member of the group can edit that single task form and click the Complete Task button. To assign individual tasks to multiple users (only possible with the Assign a Form to a Group or Assign a To-do Item action), enter each user individually in the Select Users dialog box.

  • All of the tasks assigned by a single workflow action must be completed before the workflow can continue. If the workflow action assigns individual tasks to six participants, for example, you cannot direct the workflow to continue after only three of the six tasks are completed.

  • After a task is assigned to a participant by the workflow, that task cannot be transferred to any other participant (by delegation, forwarding, etc.). However, anyone with the default Contribute permission level to the Tasks list can edit the task item and thus allow the workflow to continue.

  • A workflow can use each task only once. After you create a task by using the Custom Task Wizard, there is no way to reuse that task later in the workflow. You can create another task that performs the same function, but the task's name will have to be different and unique.

Top of Page

What is a custom task form?

Each time that you use one of the three task actions to create a task, Microsoft Office SharePoint Designer 2007 automatically generates a custom task form for that task. The custom task form is the page that is presented to the workflow participant when they edit the task in the browser.

When you create a task by using the Assign a To-do Item action, the custom task form has two buttons. The participant clicks the Complete Task when they have completed the assigned task. The custom task form for this action accepts no other input from the participant.

Custom task form for to-do item

In Office SharePoint Designer 2007, the custom task form appears as an .aspx page in the folder for that workflow. The file name of the custom task form corresponds to the name that you give the task in the Custom Form Wizard.

Custom task form in Folder List

Custom task forms are attached to the site's default master page and contain a Data Form Web Part to interact with the workflow. The custom task form can be customized for layout and appearance — for example, you can attach a different master page or modify the styles. However, to change what fields appear on the form, you must use the Custom Task Wizard in the Workflow Designer. You cannot change the form fields by editing the Data Form Web Part directly. If you make other customizations to the Data Form Web Part (for presentation and not for functionality), note that those changes are lost each time that the workflow is recompiled. Customizations to the rest of page are preserved.

To change the fields on the custom task form, you must open the workflow in Office SharePoint Designer 2007 (File menu, Open Workflow command). When you open the workflow and edit the task by using the Custom Task Wizard, you see the following warning.

Warning message

If you are using the Assign a To-do Item action, the custom task form contains only the Title and Description fields. You can freely change the text in these fields and recompile the workflow, and all running instances of the workflow continue to run using the new form.

If you are using the Collect Data from a User or Assign a Form to a Group action, the story is a bit different because the custom task form probably contains form fields that collect data. If you modify the custom task form and recompile the workflow, all running instances of the workflow continue to run using the new form. But if you delete or modify fields (for example, by changing their type or renaming them), a workflow error will occur if the running instances of the workflow reference data that is not what is expected. For example, a running workflow may do a lookup and expect a field to contain data (be non-empty) but now it is empty, or the field may have changed type. Therefore, it is important not to make any change that deletes, renames, or otherwise alters form fields that currently running workflow instances may attempt to reference.

In addition to the custom task form, each time that you use one of the three task actions to create a task, Office SharePoint Designer 2007 automatically generates a content type for that task in the Tasks list. The content type defines the available fields and what format they use, as you specified in the Custom Task Wizard. The name of the content type matches the name that you give the task in the Custom Form Wizard. For example, if you create a task named Review Document, you will see a content type with that name on the Settings page of the Tasks list.

Task content type in the browser

We recommend that you modify workflow content types only by opening the workflow in Office SharePoint Designer 2007, and not by modifying the columns or other settings for the content type in the browser. Modifying the content type in the browser can potentially break the custom task form that it is associated with.

Top of Page

Assign a to-do item

You use the Assign a To-do Item action to create the custom task form and to assign the task to one or more participants.

In this example, the task assigned to the participants is to review a document in the Shared Documents library and to mark up the document with comments and proposed changes.

  1. On the File menu, point to New, and then click Workflow.

  2. On the first page of the Workflow Designer, name the workflow, choose the list or library that the workflow will be attached to, and then select the check boxes for the start options that you want.

    First page of workflow designer

  3. Click Next.

  4. Click Actions, and then click Assign a To-do Item.

    If this action does not appear in the list, click More Actions to see the full list.

  5. In the action, click a to-do item.

    Workflow Designer page with cursor selecting a to-do item

  6. On the first page of the Custom Task Wizard, click Next.

  7. On the next page, in the Name box, type a name for this task.

    Note: The task name must be unique in the current site.

  8. In the Description box, type any general instructions to the recipient of the task.

    This description appears at the top of the custom task form, so include here any instructions that you want the workflow participant to see, not just a general description.

    Second page of Custom Task Wizard

  9. Click Finish.

    The following illustration shows how this task will be displayed to the workflow participant in the browser when they edit the task. This is the custom task form — Review Document.aspx — that you just designed by using the Custom Task Wizard.

    Custom task form for to-do item

    Back in the Workflow Designer, you still need to set the other parameter in the Assign a To-do Item action.

  10. In the action, click these users.

    Workflow Designer page with cursor selecting these people

  11. In the Select Users dialog box, type a name or e-mail address, or click an existing user or group in the list, and then click Add.

    Repeat this step to include any other participants to whom you want to assign this task.

    Notes: 

    • In the Assign a To-do Item action, the workflow creates one task for each person and group that you include here. The action does not expand the group and assign a separate task to each person in the group. For more information, see the earlier section Which action should I use to create a task?

    • Instead of entering a specific user or group name or e-mail address, you can store such information in a separate list, and then use a workflow lookup to get this information. This way, various users and groups can be configured as workflow participants without you having to modify the workflow itself.

  12. When all of the appropriate participants appear in the Selected Users box, click OK.

In this example, the workflow will now create and assign the task each time that a document is added to the Shared Documents library. The workflow will pause until every task is marked complete. The next action or step can be whatever your process requires — for example, you can configure the workflow to send an e-mail notification when all of the participants complete their reviews.

Top of Page

No comments:

Post a Comment