Michelle_Corona
ServiceNow Employee
ServiceNow Employee

Introduction


A workflow can be likened to the Six Million Dollar Man-it can be rebuilt, with new activities improving the automation of a process. During the lifespan of a workflow, many versions and contexts are made. A context is an active running instance of a workflow. After discussing workflow contexts in class, I wondered when the ServiceNow system creates contexts. Is a context just a copy? How are contexts related to workflow versions?

Workflows are Automatically Versioned


When a published workflow is checked out, a copy is created. When this workflow copy is published, a new workflow version is created. Versions are date-stamped and stored in the Workflow Version [wf_workflow_version] table. Once a workflow is underway a workflow context is automatically created.

Now let's relate versions to contexts. Each running context is tied to a workflow version, not to a workflow name. This makes it possible to apply the new workflow version to new requests, but still run the old requests under the old workflow version. You can identify the current active version of a workflow, that is the one that will be applied to a new request, as having the Published field set to true. Versioning is an internal function meant to keep currently-processing workflow contexts from interfering with previous workflow contexts.

Advantages of Workflow Contexts


Some of the advantages of workflow contexts are:
- Provide a record of approval information - who approved the request and when was the approval done.
- Set processing start and end dates. This provides a time framework for the length of the process and information on the span of the stages.
- Give the requester feedback in recognizable, pre-defined stages which are set by each activity in the workflow. More than one activity, approval and notification can be in a stage. Fulfillment, Backordered and Waiting Approval are all examples of stages.
- Document which processing paths were taken.

Workflows can be moved between instances using an update set. Any time an update set is applied to an instance, any running workflow will continue to execute following the workflow version they were started under. There can be many active contexts at any given time.
3 Comments