In Leapwork, you can build reusable automation components, known as sub-flows.
-
They enable you to design automation flows faster and significantly reduces maintenance time.
-
Sub-flows consist of existing building blocks that fulfil a repetitive step, for example, actions such as login and logout.
-
They can also be made up of other sub-flows.
Sub-flows can be added as many times as needed inside any automation flow.
Note: The screenshots on this page use the Elegance Design, introduced in 2025.3. If you are using an earlier version, your layout may look different.
Creating and organizing sub-flows
Sub-flows can be created in two ways:
-
One way is to select building blocks that make up part of an existing automation flow:
-
Right-click on one of the selected elements.
-
Choose Create Sub-flow. This wraps all selected building blocks and connectors into a new sub-flow, then prompts you to title it:
-
In the example above, four building blocks form a new sub-flow named Check total:
-
The second way to create a sub-flow is to right-click anywhere in the flow tree-view and select the Create sub-flow option. This creates a new, empty sub-flow.
Sub-flows are shown with this icon in the flow-tree:
You can drag sub-flows to any folder or below a specific flow. Since sub-flows are shared across all folders and flows in the tree view, organizing them in a dedicated folder makes them easier to find and clarifies their purpose.
Adding sub-flows to a flow
To add a sub-flow to a flow:
-
Drag the sub-flow from the tree view onto the Leapwork Design Canvas.
-
Another way is to right-click the design canvas:
-
Select Add new building block.
-
Then choose the sub-flow from the Sub-flows category.
-
Editing a sub-flow
There are several instances where you would want to edit an existing sub-flow. For example,
-
To add parameters and additional connectors
-
To simply update the functionality inside the sub-flow
-
To rename the sub-flow.
When a sub-flow is updated, all dependents (flows using the sub-flow) are automatically updated. This is why using sub-flows is a great way to reduce the burden of maintenance.
To edit a sub-flow:
-
Either right-click the building block from the Design Canvas.
-
Select Edit Sub-flow or open it from the tree-view structure:
Adding parameters
Adding parameters is a valuable feature of sub-flows. This increases the re-usability and allows for the sub-flows to be completely data driven.
Parameters are defined by a specific category of building blocks that can only be used inside sub-flows: Value Input and Value Output.
A sub-flow can have any number of input and output parameters. You can rename these parameters by changing the names of the Value Input and Value Output building blocks.
To change the name:
-
Double-click on the title of the building block.
-
Enter the new title.
In the example below, one input parameter is added to the sub-flow. The parameter is renamed Value A:
When this sub-flow is added to a flow it will look like this:
Connectors to sub-flows
The green connectors on a sub-flow are defined by a specific category of building blocks called Execution Input and Execution Output. It is possible to have multiple connectors to and from a sub-flow, although typically only multiple output connectors are used.
Multiple output connectors means the sub-flow can handle branching of the flow.
In the example below:
-
The sub-flow has two output connectors depending on the comparison operation. If the input value matches 200, then the top green connector is triggered. Otherwise, the Incorrect green connector is triggered.
-
To make the sub-flow even more useful, the second green connector has been renamed to No match.
When this sub-flow is used in a flow it looks like this:
Renaming a Sub-flow
When a sub-flow is added to an automation flow, the sub-flow will by default have the given name of the sub-flow, i.e. the name shown in the tree-view.
Note: Whenever a sub-flow is changed, it is automatically reflected in the flows containing the sub-flow, except for changes made to the name of the sub-flow.
Once you have added a sub-flow to a flow, you are free to change the title of the specific instance of the sub-flow building block inside the flow. This means that if the name of the sub-flow is changed, i.e. by right-clicking in the tree-view and selecting Rename, then the title of the sub-flow block in the current flow will be changed.
Want to learn more about Sub-Flows? Follow this resource to begin.