Thursday, December 12, 2013

Creating a custom sequential workflow similar with SharePoint OOTB approval workflow (6) reassign task and request change


Creating a custom sequential workflow similar with SharePoint OOTB Approval workflow (1) Association / Initiation Form
Creating a custom sequential workflow similar with SharePoint OOTB Approval workflow (2) Custom Activity, While Activity and Replicator Activity
Creating a custom sequential workflow similar with SharePoint OOTB Approval workflow (3) custom Content Type and custom Task Edit Form
Creating a custom sequential workflow similar with SharePoint OOTB approval workflow (4) End on first rejection
Creating a custom sequential workflow similar with SharePoint OOTB approval workflow (5) cancel task(s) when item changed
Creating a custom sequential workflow similar with SharePoint OOTB approval workflow (6) reassign task and request change

a.     Add one more While Activity


Both reassign task and request change functionality need to create new task repeatedly, so we need to add one more While Activity.
Based on the workflow described in Creating a custom sequential workflow similar with SharePoint OOTB approval workflow (5) cancel task(s) when item changed, drag from the toolbox and drop an WhileActivity into replicateTask activity, and put the original SPTaskActivity1 in this While Activity(whileActivity2) like following:



b.     Communications between task edit form, custom activity and workflow.

Communications between task edit form and custom activity are based on the custom content type, and communications between workflow and custom activity are based on the respective properties declared in each class.

The most important field is “ApprovalStatus”.  The original value is 0, in task edit form,  if Approve button is clicked, it is 1, 2 for Reject, 3 for Reassign Task, 4 for Request Change, and 5 for response to request change. If a task is completed with ApprovalStatus as 1 or 2, that means approved or rejected, this task is finished. If the task complete with ApprovalStatus as 3,4 or 5, the task is not finished, the new added whileActivity2 will create a new task respectively.

This logic can be included in the whileActivity2’s code condition method.

No comments:

Post a Comment