Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.

Subflows

Log in to subscribe to topics and get notified when content changes.

Subflows

Define a sequence of reusable actions that can be started from a flow, subflow, or script. Define inputs and outputs to pass data to and from the subflow.

All subflows consist of properties, one or more inputs, one or more outputs, a sequence of actions, and the data collected or created. Unlike flows, subflows:

  • Do not have a trigger and are instead started from a parent flow, subflow, or script by a method call.
  • Include inputs to specify data available to the subflow when it starts.
  • Include outputs to specify data available to the parent flow after the subflow ends.

Using subflows, process analysts can:

  • Create a set of reusable operations for use in multiple flows.
  • Add flow logic in addition to actions.

Subflow properties

The subflow properties specify the subflow name, application, category, description, in-flow annotation, and status. Flow designers can update the subflow name, category, description, and in-flow annotation at any time, but can only set the application during subflow creation. The subflow status is set when you save or publish a subflow.

Subflow inputs

Subflow inputs specify the data available to the subflow when it starts. Each input you define for a subflow becomes a configuration option in the Flow Designer interface. To use the subflow in a flow, flow designers must define a value for each mandatory input. The more inputs a subflow has, the more data flow designers must define and the more familiar they must be with the underlying data model to use the subflow effectively.

Inputs provide advanced options based on their data type. All inputs have advanced options to add a hint or provide a default value. Use advanced options to guide flow designers through adding and configuring a subflow to a flow. For example, create a choice input to provide flow designers with a pre-defined list of configuration options to choose from. For more information about the configuration options available to particular data types, see field types.

Subflow outputs

Subflow outputs specify the data available to the parent flow after the subflow completes. Subflow outputs are defined as variables with a name and data type. Subflow designers assign values to an output using the Assign Subflow Output flow logic. Output values can be based on the subflow logic conditions, action results, or a manually set value. For example, an output may have one value when a condition is met and another value when a condition is not met. During runtime, the value of the output is determined by the condition that is met.

Consider the following example of a subflow with two conditions that both result in a value for a single output variable. The value of the variable depends on which condition is met during runtime.

Outputs
[Manager ID] [String]
Actions
  • 1 Look Up [User] Record where (Created on Today)
  • 2 If ([1->User Record->Title] contains Manager) then
    • 2.1 Assign Subflow Outputs [Manager ID] to [1->User Record->User ID]
  • 3 Else
    • 3.1 Assign Subflow Outputs [Manager ID] to [1->User Record->Manager->User ID]

In this case, if the user's title contains "Manager" then the user ID is assigned as output. Otherwise, the subflow looks up the user's manager and assigns the user ID of the manager as output.

Flow Designer allows you to define a value for the same variable multiple times. However, if a variable is given two or more possible values without conditional logic, only the last value defined in the subflow is applied to the output at runtime.

Outputs

[Manager ID] [String]

Actions
  • 1 Look Up [User] Record where (Created on Today)
  • 2 Assign Subflow Outputs [Manager ID] to [1->User Record->User ID]
  • 3 Assign Subflow Outputs [Manager ID] to [1->User Record->Manager->User ID]

In this example, action three overwrites the value of action two and [1->User Record->Manager->User ID] is applied to the [Manager ID] output at runtime because it was the last value defined. Typically, subflows should only include multiple values for one variable if conditional flow logic is used.

Actions

Within Actions, flow designers can add actions, flow logic, flows, or other subflows.

An action is a reusable operation that enables process analysts to automate Now Platform features without having to write code. For example, the Create Record action allows process analysts to generate records in a particular table with particular values when certain conditions occur. Core actions like Create Record require some familiarity with Now Platform tables and fields. Action designers can create application-specific actions to pre-set configuration details. For example, creating a Create Incident Task action ensures that the process analyst uses the correct table and field configuration each time the action is used. You can add application-specific actions by activating the associated spoke.

Flow logic

Subflows can contain flow logic to specify conditional or repeated actions, or to assign output variables to subflow data. The system provides these flow logic options.

Table 1. Available flow logic
Flow logic Description
For Each Applies actions to each record in a list of records. Flow designers must specify the list of records from the subflow data.
Note: Add a For Each flow logic block inside of another to repeat an action over a series of records. However, avoid nested For Each loops that process many records. Nested loops may cause the flow to run until stopped by the flow transaction quota rule, which prevents flows from running longer than an hour. For more information about transaction quotas, see Transaction quotas.
If Applies actions when a list of conditions is met. Flow designers can specify the conditions with subflow data. Once an If condition is added, you can add an Else or Else If flow logic option to define behavior when conditions are not met.
Assign Subflow Outputs Assigns an output variable to subflow data. Only outputs defined in Inputs & Outputs can be assigned a value. Assigning outputs enables you to assign a different output variable for each logical path in the subflow.

Testing subflows

You can test a subflow alone, or when added to a flow. When testing a subflow alone, you must define the inputs that the subflow uses in its actions. Because a subflow does not have a trigger, testing a subflow runs the actions using the defined input values.

Note: Flow designers should always test flows and subflows on sub-production instances containing relevant demonstration data since testing a subflow creates or changes records on the instance.

Roles

To access subflows, a user must have the flow_designer or admin role.

Feedback