Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007 (part 4/20)

 

image

By Serge Luca

image

 

Step 4/20. Creating the tasks

 

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.

Let’s drag and drop a CreateTask activity before the requestManagerApproval activity:

 

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:

 

        private void ApproveRejectTask_MethodInvoking(object sender, EventArgs e)
        {
            this.ApproveRejectTaskId = Guid.NewGuid();
            this.ApproveRejectTaskProperties.ApproveRejecTaskProperties.Title = "Approve or Reject this expense report";
            this.ApproveRejectTaskProperties.AssignedTo = Manager;
        }

 

Remove the requestManagerApproval activity.

OnTaskChange activity

Add a new OnTaskChange activity and rename it WaitForApprovalRejection:

 

Any event OnTaskChanged 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.

CompleteTask activity

Name it ApproveRejectTaskComplete.

Set the correlation token to ApproveRejectToken.

Bind the TaskId property to an existing member: ApproveRejectTaskId.

Test

Rebuild the solution, call the install.bat and test your workflow : a new task should have neen assigned to Jim:

The workflow status will be In progress which is a good indication that the workflow is waiting for an event:

If we click on the status, we’ll get more details:

 

 

Indeed, a task has been assigned to Jim; if you click on the task Title, you’ll be redirected to the task list:

 

 

If you click on the task you’ll get more details (including the workflow association name: AcceptReject):

 

 

If Jim change the task and set it to completed:

 

The workflow will complete. There are many situations where the out of the box behavior is not enough, for instance if you want to display more detailed informations about the expense report, or more specific replies (approved or rejected).

Then we need to create either  Infopath forms (only on MOSS) or aspx form (on Wss v3 or on MOSS).


This hands-on training is the property of Redwood S.L sprl and may not be organized in class or in group without the prior written permission of Serge Luca. Should you wish to organize this hands-on training in your company or institution, please contact Serge Luca  first to enter into a licence agreement. Each trainer or teacher using this hands-on training should have a licence agreement. Please ask your trainer or Serge Luca whether he or she has entered into a licence agreement with Redwood S.L sprl.

The hyperlink to this hands-on training may be placed on your website for free, on the condition that the name Serge Luca is clearly mentioned in the reference. Please send us a mail containing the link to the web page our reference is used on.


Advertisements

One response to “Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007 (part 4/20)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s