Creating a Workflow
| Note: This article applies to Fuji. For more current information, see Workflow at http://docs.servicenow.com
The ServiceNow Wiki is no longer being updated. Please refer to http://docs.servicenow.com for the latest product documentation.
- 1 Overview
- 2 Creating a Workflow
- 3 Configuring Additional Properties
- 4 Creating Workflows in Versions Prior to Fuji
- 5 Canceling Workflows
- 6 Ending Workflows with Multiple Branches
- 7 Editing Published Workflows
- 8 Sample Workflows
Users with the workflow_admin or workflow_creator roles can use the Workflow Editor to create workflows. If you are designing the workflow as part of an update set process, see Moving Workflows with Update Sets before creating the workflow. Also, make sure you understand how workflow scoping can affect a workflow's access to information. The scope of a workflow cannot be changed after it is created.
|Note: For information on creating workflows in Eureka and Dublin, see Creating Workflows in Versions Prior to Fuji.|
2 Creating a Workflow
When you create a new workflow, the editor presents key properties for configuration. Additional properties are available for configuration after you submit the workflow. For details, see Configuring Additional Properties.
To create a new workflow:
- Navigate to Workflow > Workflow Editor.
- The Welcome tab displays links to workflow documentation and other related resources. If ServiceNow Orchestration is activated, the welcome screen contains resources for that feature as well.
- Select the Workflows tab in the palette, and click the + icon.
- Complete the fields in the General, Schedule, and Documentation tabs.
- Create the workflow by clicking Submit in any tab.
- In the title bar, click the menu icon () and select Properties.
- Complete configuration of the additional workflow properties.
- Build the workflow by dragging activities onto the canvas and configuring activity properties.
- See Adding Workflow Activities for details.
- If your workflow contains branches of activities, verify that the workflow ends correctly.
- For more information, see Ending Workflows with Multiple Branches.
- Validate the workflow.
- Publish the workflow by clicking the menu icon and selecting Publish.
- The workflow is then activated and can be used according to the defined properties.
- The workflow is then activated and can be used according to the defined properties.
|Note: Publishing a new version of a workflow does not change any workflow contexts that were created before the new version is published.|
|Name||A unique name to identify the workflow. Workflows cannot be created with the same name as an existing workflow, starting with the Eureka release.|
|Table|| The table for the workflow to run on. Workflows that run on specific tables can still interact with other tables. Select Global [global] to run the workflow on all tables.
All users who edit the workflow must have access to the necessary tables and domains.
|Order||Numeric value that determines the order of the workflow, relative to other workflows. Workflows are evaluated in order from the lowest order number to the highest. A workflow runs if it is the first to match conditions.|
|Max activity count||[Required] The maximum number of activities performed by the workflow. This value is used to prevent infinite loops and is set to 100 by default. When the stated maximum count is reached, the workflow is canceled. If this field is blank, the maximum count is set to -1, and the workflow is canceled.|
|Activity pinning|| List of options that control updates to custom activities at the workflow level. Pinning protects custom activities from being updated automatically when downloaded from the ServiceNow Store. For more information, see Activity Pinning. Pinning is available starting with the Fuji release. The possible options are:
|Application||[Read-only] Scope of this activity. For more information, see Application Scope.|
|Accessible from|| [Read-only] Scope restrictions for this workflow. Possible settings are:
For more information see Workflow Scope.
|Checked out||[Read-only] When the workflow was checked out. Automatically set by the Checkout action in the workflow menu.|
|Checked out by||[Read-only] The user who has this workflow checked out. This value is automatically set by the Checkout action in the workflow menu.|
|Published||[Read-only] Check box to indicate whether the workflow has been published. Automatically set by the Publish action in the workflow menu.|
|If condition matches|| When the condition evaluates to true, the workflow launches in an active context:
|Condition||A condition builder for specifying workflow conditions that trigger the behavior selected from the If condition matches list.|
Create a schedule for this workflow using the schedule builder.
|Delivery based on|| The schedule type for this workflow. Possible types are:
|Expected time||User-defined interval. This field is available when the schedule type is User-specified duration.|
|Schedule||Preconfigured schedule that determines when this workflow runs.|
|Timezone||Time zone for this instance.|
The Documentation tab displays the name of the current workflow's author and a description of the workflow's purpose.
3 Configuring Additional Properties
To finish configuring your new workflow, submit it. Then reopen the Workflow Properties form by clicking the information icon in the title bar or clicking the menu icon and then selecting Properties. These additional properties are available for configuration:
The Inputs tab lists all the activities in the current workflow that input data, the data type, and the default value. To create a variable, click New.
|Reference||Name of a field used as a reference field.|
|Default value||Default value for this input data|
|Stage field||The field on the table that will be updated with the stage information. If this value is not specified, the default stage field for the table is used. For more information, see Using Workflow Stages.|
|Stage Rendering||The renderer to use when displaying stage icons on a form or list view. For more information about renderers, see Rendering Workflow Stages.|
|Stage order||The order of workflow stages when you view a workflow field in a list. Select Computed to let the workflow engine compute the stage order from the order of execution in the workflow. Select User Specified to use the Order field from that workflow's stages.|
3.3 Estimated Runtime
The Estimated Runtime tab opens the controls for configuring the ERT for the workflow. Core workflows included in the base system are not configured for estimated run time by default. All new workflows are configured with default ERT values automatically. You can edit existing run time estimates or configure new ones for any workflow. For details about how estimated run times are configured and calculated, see Workflow Run Time Metrics.
|Requires ERT||Check box to indicate that this workflow requires an estimated runtime configuration. You can use the ERT calculations to determine if workflows are running longer or shorter than expected and to identify errors in workflow processing. By default, new workflows require an ERT.|
|Estimated Run Time||The initial estimate for the workflow's run time.|
|Number of data points||[Read only] The number of times the system has compared the estimated run time to an actual run time result.|
|Outlier Percentage Threshold for ERT||[Required] The percentage deviation from the estimated run time that identifies an outlier workflow run time. The system uses a default value of 20. For more information, see Identifying Outlying Run Times.|
The Version tab lists all versions of the current workflow. When you create a new workflow, this list is empty.
3.5 History (Past Contexts)
The History tab lists all the contexts for the current version of the current workflow. This list is empty until the workflow has run.
4 Creating Workflows in Versions Prior to Fuji
|Click the plus for instructions on creating workflows in versions prior to Fuji.|
4.1 Creating a Workflow
There are three major steps to creating a workflow:
4.1.1 Defining Workflow Properties
Workflow properties are defined when a new workflow is created. To change the property settings, open the workflow actions menu () and select Properties or click the Properties icon () beside the workflow name.
The following properties can be defined for a workflow:
4.1.2 Configuring Workflow Properties
The Workflow Properties form cannot be configured from inside the graphical workflow editor. To configure the Workflow Properties form, navigate to Workflow > Workflow Versions, select a workflow, and configure the form.
5 Canceling Workflows
You can use a script action to cancel executing workflows. This can be helpful in cases where a workflow must be canceled in response to an event or where a user must manually cancel a workflow.
For details on the script, see cancelContext(context).
6 Ending Workflows with Multiple Branches
A workflow is complete when it reaches the End activity, even if there are still active branches of the workflow in progress.
For example, the following figure shows a workflow with two branches that execute independently. When Task 1 and Task 2 of Branch B are completed, the workflow is marked complete even if the Branch A tasks are not completed.
To ensure that both branches are completed, add a Join activity to resolve the branches. When one branch reaches the join, the workflow waits for the other branch. When both branches are complete, the workflow reaches the end. The Incomplete condition is met only if one of the branches cannot be completed.
7 Editing Published Workflows
After the workflow is published, you can edit it by clicking the menu icon in the title bar (gear icon in releases prior to Fuji) and selecting Checkout. A new workflow version is then created and assigned to you. If you are in a different domain than the published workflow, the new workflow version is created in your domain starting with the Eureka release.
8 Sample Workflows
Because of the flexibility of workflows, you can create many different types. The following list contains several workflow samples: