07/12/2012

SharePoint 2010 Workflows

SharePoint 2010 Workflows - termination and cancellation


Cancelling a workflow stops the workflow, but all tasks connected to the workflow is still there.
Terminating a workflow stops the workflow and roll back or delete all tasks.

Some times termination does not work the correct way and email notifications are still sent to the task owners.

In the database the workflows are stored in the Workflow table. The Workflow table contains a column named InternalState, the value in this column are set by using the SPWorkflowState enum. When InternalState is 128 the workflow is terminated. The SPWorkflowState enum have these values:

public enum SPWorkflowState
{
    None = 0,
    Locked = 1,
    Running = 2,
    Completed = 4,
    Cancelled = 8,
    Expiring = 16,
    Expired = 32,
    Faulting = 64,
    Terminated = 128,
    Suspended = 256,
    Orphaned = 512,
    HasNewEvents = 1024,
    NotStarted = 2048,
    All = NotStarted | HasNewEvents | Orphaned | Suspended | Terminated | Faulting | Expired | Expiring | Cancelled | Completed | Running | Locked, /* 4098 */
}

The workflow state can be changed by using the WorkFlow API: SPWorkflowManager.CancelWorkflow

No comments:

Post a Comment