SharePoint 2010 workflow tutorial
- Step 1.
- Step 2.
- Step 3.
- Step 4.
- Step 5.
- Step 6.
- Step 7.
- Step 8.
- Step 9
- Step 10.
- Step 11.
- Step 12
- Step 13.
- Step 14.
- Step 15.
SharePoint 2007 workflow tutorial
- Step 1.
- Step 2.
- Step 3.
- Step 4.
- Step 5.
- Step 6.
- Step 7.
- Step 8.
- Step 9.
- Step 10.
- Step 11.
- Step 12.
- Step 13.
- Step 14.
- Step 15.
- Step 16.
- Step 17.
Scenario
If the expense reports requires the manager approval, we want the manager to receive a task in his task list in order to approve/reject the expense report.
CreateTask activity
Let’s drag and drop a CreateTask activity before the askManager activity and name it approveRejectTask
Set its Correlation token to ApproveRejectToken and the associated ownerActivityName to ExpenseReportWorkflow:
Bind the TaskProperties property to a new member (click on he ellipsis button…):
Bind the TaskId to a new member (field): ApproveRejectTaskId.
Double click on the ApproveReject task to generate a new event handler and store a new Guid into ApproveRejectTaskId, set the task title, and associate the task with the manager:
Remove the askManager activity.
OnTaskChange activity
Add a new OnTaskChange activity and rename it waitForApprovalRejection:
Any event coming form the task will be handled by the waitForApprovalRejection activity if we group them with the same correlation token (you ‘ll have a better understanding of the correlation token in the next tutorial).
Set the correlation token to ApproveRejectToken.
This is not enough, the event doesn’t carry the taskId : you still need to associate this activity with the taskId:
Bind the the TaskId property to an existing member: ApproveRejectTaskId.
If we consider that when the user replies, the task should complete, then we need to drag and drop a CompleteTask activity
CompleTask activity
Name it approveRejectTaskComplete.
Set the correlation token to ApproveRejectToken.
Bind the TaskId property to an existing member: ApproveRejectTaskId.
Just to make sure everything will work ok, change the Show field setting of the Created By column the Expense Reports list to account;
Do this as well for the column Manager and Manager Of (list Managers).
Log in a BrianC, add an expense report and run the workflow : the workflow should have the status “In Progress” as illustrated in the next picture :
The workflow is actually waiting for an event in the waitForApprovalRejection activity : the event will be trigger when a task will be edited.
In the Tasks list a task as been created and assigned to Brianc manager : Amay Albert as illustrated in the next picture :
When we click on the task title, the following dialog will show up
If we edit the task and set the task as completed (for instance).
The task form that shows up is the default task form; we will replace it with a customized form in a next version of this tutorial.
The workflow is not In Progress (it is not waiting anymore)
Source code can be downloaded here.