WSS Workflow Modification Form

It is easy to find WSS ASP.NET samples for Instantiation and Task Edit forms, but it is hard to find sample for Modification form. Maybe many people think there is no much difference, but is that true?

Modification form is quite useful in WSS work flow. For example, after a long running task has been assigned to an analyst, the analyst takes vacation for weeks. At this point, the Modification form can be used to reassign the task to another person.

You can define Modification form in Feature file with the similar way for Instantiation form. But how about the workflow part?

Instantiation form happens at the very beginning of a workflow, but Modification can happen anywhere in a scope.

A common way to define Modification in workflow is to put EnableWorkflowModification activity inside an EventHandlingScope activity. Other activities inside the same scope do the normal work. When Modification form is accessed, an event will raised to the workflow, so that the EventHandlingScope activity can handle the event and call event handler.

In Visual Studio, right-click the EventHandlingScope activity and select "view event handlers":

Then you can add OnWorkflowModified and UpdateTask activities to the EventHandlersActivity:

The Modification activities have their own ContextData and CorrelationToken, because they are actually outside the normal workflow.

One issue I saw: If there is an OnTaskChanged activity already defined in the EventHandlingScope (like below), you had better not add another OnTaskChanged activity inside the EventHandlersActivity; otherwise, you would be surprised to see only one OnTaskChanged activity is called.


Anonymous said...

Do you know how reinitialize the SPWorkflowModification.ContextData after a modication is made?

For example, if the Approver is changed in the workflow fields (and in the task via an UpdateTask activity), a subsequent modification will still have the original approver in the ContextData.

Note: the SPWorkflowModification.ContextData property is Read Only in the modification form itself.


Anonymous said...

Do you know if it's possible to create a workflow modification without a form? I need to programmatically change which workflow history list the current instance of the workflow is using at the very beginning of the workflow, so there is no "form" to interact with. I just need to trigger whatever event will cause the modification to occur.

Jun Meng said...

To anonymous:

If you want to do something at the very beginning of the workflow instance, you need add logic in workflow instantiation form. Users need that form to do initial work anyway.

Galia Co Hagan said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.