You build a subflow in Workflow Studio by choosing New, then Subflow, then naming it, setting its scope and run-as behaviour, defining its inputs and outputs, and adding actions. Once it exists, you can convert steps from an existing flow, copy it under a new name, test it, publish it, and restore an earlier version from its history.
Before you build a subflow
Building a subflow requires the flow_designer or admin role. A subflow can create and change records, so check the application table structure and any business logic on the tables it touches, and disable conflicting business rules or workflows first. For the wider concept, see the business rule guide. If you plan to deploy the subflow through an application repository or the ServiceNow Store, create a custom application to hold the content from the start. To understand what a subflow is before you build one, read the subflow concept guide first.
Creating a subflow in Workflow Studio
Open All, then Process Automation, then Workflow Studio. Select New, then Subflow. The properties screen asks whether to build with Now Assist or manually. This section covers the manual route. The Now Assist route turns text directions, an image, or both into a subflow preview. It needs the now.assist.creator role along with admin, flow_designer or delegated developer permission, and each generate or regenerate counts as an assist against your Now Assist subscription. Workflow Studio does not save previews, and discarding one loses all information about it, so select Save and edit subflow to keep the outline and review it.
| Property | What it controls |
|---|---|
| Subflow name and Description | Identify the subflow and explain what it does. |
| Application and Domain | The application and domain scope the subflow is created in. |
| Accessible From | Whether it is available across all application-scoped code or only within its own scope. |
| Category | A grouping inside the scope. From the Xanadu release you can create custom categories. |
| Protection | Whether the subflow is read-only. You can set this only in a scope you own. The default is None. |
| Subflow annotation | Help text under the title in Workflow Studio, for flow authors. |
| Run as | Runs the subflow as the system user or as the user who starts the session. |
| Flow priority default | Low, Medium (the default) or High. |
Running as the initiating user limits the subflow’s actions to that user’s access controls and respects their date and time format. Before you choose this option, check that your security restrictions allow every change the flow executes, because the initiating user’s access controls apply to each action. For the wider topic, see the instance security and access control guide. The Run with roles field appears only with this option, and Run as does not pass down to child subflows.
Defining inputs and outputs
Inputs are the data the subflow has when it starts. Each one becomes a configuration option for flow designers, and each mandatory input needs a value before the subflow can be used, so add just the inputs it genuinely needs. Every extra input also means more data for designers to supply and more familiarity with the data model the subflow works on. In the Inputs & Outputs pane, add a name and a type, then tick Mandatory where a value must be supplied. Advanced options vary by type and can include a hint or a default value. A choice input, for example, gives designers a predefined list to pick from.
Outputs describe what the parent flow receives when the subflow completes. Give each a name and a data type, then assign values in a later step. Input and output names cannot use sys_id, sys_created_by, sys_created_on, sys_updated_on, sys_updated_by or sys_mod_count, which are reserved.
Adding actions and assigning outputs
Under Actions, choose Action, Flow Logic or Subflow. Actions can come from Workflow Studio, from custom actions built by a user with the action_designer role, or from the Integration Hub and Spokes plugins. Flow logic covers conditional and repeated operations. Drag the handle on an action to reorder it, and select Done when each one is configured. For the wider concept, see the action concept guide.
To set outputs, choose the plus control under Actions, select Flow Logic, then Assign Subflow Outputs. Pick an output, then enter a value or a data pill. One output can take several values, which is how you produce conditional results. A subflow must contain at least one action before you can test or publish it.
Converting existing flow items into a subflow
If a flow already contains the steps you want, you do not need to rebuild them. Open the flow in Flow Designer and select Select multiple beside the Actions header, which appears once the flow has at least two actions. Tick consecutive actions, choose the Convert to subflow icon in the Operations menu, enter a name, and select OK. You need write access to the flow, and a read-only protected flow cannot be converted. A Set Flow Variables block cannot move into the new subflow, so define those variables inside the subflow where they will be used.
The selected actions are replaced by a Call a subflow block. The new subflow lands in the same application scope, carries the same actions, input values, references and transform functions, and is published. Review it afterwards, then supply the input values the original flow now needs.
Copying a subflow to a new name or scope
Copy a subflow to rename it or to move it into another application scope. You need admin or flow_designer rights and write access to the subflow. In Workflow Studio, select Subflows on the homepage, open the more actions icon for the subflow, choose Copy subflow, enter a unique New subflow name, optionally choose an Application, and select Copy. The copy keeps the same properties, inputs, actions, flow logic and outputs. For the wider concept, see the application scope guide. If Copy subflow is missing, the subflow may have a protection policy, which blocks copying, or you may lack the user role or developer permission.
Testing a subflow before you publish
Testing needs the flow_designer or admin role. Open Flow Designer, select the subflows tab, open a saved subflow, select Test, define the inputs, and select Run Test. A subflow has no trigger, so the test runs its actions against the values you set, and later tests reuse those values unless you change them. Testing creates or changes records, so run it on a non-production instance that holds relevant demonstration data. If you choose the background option, execution details appear only after the run completes, and they attach to the subflow at that point. Review the Execution Details before you publish.
Conversational subflows are tested differently. Choose Trigger via a conversation, pick a conversational skill and an AI assistant, and answer the assistant’s questions. A subflow can have more than one conversational skill. The conversational subflows guide covers that setup.
Publishing a subflow
Publishing also needs the flow_designer or admin role, and the subflow must have been tested first. In Flow Designer, select the subflows tab, open the tested subflow, and select Publish. Publishing makes the subflow available to other users and to activated flows. Later edits stay in draft until you publish again. Parent flows that use the subflow move to the current published version after you publish, so an unpublished edit will not reach a parent flow when it runs.
Tracking and restoring subflow history
Open the subflow in Workflow Studio, select Edit subflow, then choose the History icon in the sidebar. Each entry shows its time stamp, the user who made the change, the operation type and any annotation. Entry types include Force saved, Deactivated, Activated/Published, Autosaved, Restored and Deployed. You can filter the list by entry type or by user, annotate an entry, mark it as a favorite, or save it as a new subflow.
How much history is kept
By default, Workflow Studio stores 100 history records per flow. Once that limit is passed, it overwrites the oldest entry that is not a favorite. The maximum is controlled by the sn_flow_designer.maximum_flow_history_records_per_flow system property. Each subflow can hold up to 20 favorites, and when it reaches that limit you must remove one before adding another. Autosaves by the same user within a 60-minute window merge into a single entry. That window is set by the sn_flow_designer.autosave_version_interval system property.
Restoring an earlier configuration
Select the entry you want in the History list and review its configuration in the Flow History view. Select Restore, then confirm. The restored subflow duplicates that entry’s actions, flow logic, subflows and data configuration, and the restore itself creates a new history entry. If you want to keep an earlier version as a separate subflow instead, use the save-as-copy option on that entry.
Frequently asked questions
Which roles can build, test and publish a subflow?
Building, testing and publishing require the flow_designer or admin role.
Why does the Copy subflow option not appear?
Either the subflow has a protection policy, which blocks copying, or you lack the user role or developer permission that copying needs.
Do parent flows pick up changes as soon as I save a subflow?
No. Changes stay in draft until you publish again. After publishing, parent flows that use the subflow move to the current published version.
Can I undo a change to a subflow?
Yes, if the earlier configuration is in the history. Open the History view, select the entry, and restore it. The restore creates a new history entry, so the state you replaced is still recorded.
For a broader set of flow authoring pages, return to the Flow Designer hub.