Flow & Subflow

AyoubF
Giga Contributor

As a beginner, I understand what Flows and Subflows do individually, but how do I know when I should use a Subflow instead of keeping everything inside one Flow?

2 REPLIES 2

Dr Atul - LNG
Tera Patron

Hi @AyoubF 

 

https://www.servicenow.com/docs/r/build-workflows/workflow-studio/when-to-use-flow-types.html

 

 

When to use different flows
If... Then create...
You need a constant input to initiate a set of actions A flow
You need a variable input to initiate a set of actions A subflow
You want to start a flow by calling it from another flow or script A subflow
You want to reuse a set actions in other flows A subflow
You want to configure different types of inputs for each call A subflow
You want to specify the inputs available to a subflow when it starts A subflow
You want to specify the outputs available to a parent flow after a subflow ends A subflow
You have a large flow with 25 or more actions and want to improve its performance and readability Subflows
There are interrelated outputs or some action must be taken when all are available Parallel subflows
There are not interrelated outputs or some action must be taken when all are available Multiple flows triggered by a single event
You want to correct certain errors in your record data automatically A subflow
You want to avoid the limit of 10 items in the error-handling-process A subflow
You want to use subflow outputs to trigger automation in other flows A subflow

vaishali231
Mega Sage

Hey @AyoubF 

I would suggest following a simple approach: use a Flow to manage the overall business process and a Subflow to handle reusable or logically independent operations.

Here is how I decide between them:

 Use a Flow when:

  1. You are implementing a specific end-to-end business process.
  2. The logic is used only in that particular process.
  3. The steps are straightforward and easy to maintain.
  4. There is no requirement to reuse the same logic elsewhere.

Use a Subflow when:

  1. The same logic needs to be reused across multiple Flows.
  2. You have a group of actions that perform a specific business operation.
  3. The main Flow is becoming too complex and difficult to maintain.
  4. You want to centralize common logic and avoid duplication.

Practical Example:

Consider an Incident Management process:

Main Flow:

  1. Trigger when an Incident is created.
  2. Check Incident priority.
  3. Assign the appropriate group.
  4. Call a Subflow to send notifications.
  5. Update the Incident.

Now, suppose the same notification logic is also required in Change Management and Service Catalog processes.

Instead of duplicating the notification steps in every Flow, create a reusable Subflow called Send Notification and call it wherever required.

My Recommendation:

Before creating a Subflow, ask yourself:

  1. Will I reuse this logic in another Flow?
  2. Does this functionality represent an independent business operation?
  3. Will separating it improve readability and maintenance?

If the answer is yes, consider using a Subflow. Otherwise, keeping the logic within the main Flow is perfectly fine.

In short:

Flow = Manages the overall business process.

Subflow = Handles reusable or logically independent operations.

The goal should be to keep your Flow simple, readable, reusable where necessary, and easy to maintain. Avoid creating unnecessary Subflows for every small operation.

*************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb