Screen Sub Flow

📘

Available since: OpenLegacy version 3.0.34

Screen Sub Flow is a modular flow-composition capability that lets you extract, encapsulate, and reuse discrete portions of a screen flow across your project. This guide explains what Sub Flow is, why it matters, and how to put it to work in the Screens Designer.

What Is a Sub Flow?

Starting from version 3.0.34, OpenLegacy introduced Screen Sub Flow in Screens Projects.

A Sub Flow lets you build short, business-specific flows and reuse them anywhere across your project. The simplest way to think about it is as a method inside a method, a self-contained unit of logic that you define once and call as many times as you need.

Each Sub Flow is fully encapsulated:

  • Its own input - pass parameters into the Sub Flow when you invoke it.
  • Its own output - returns values back to the calling flow once it completes.
  • Its own variables - define and use local variables that live only within the scope of the Sub Flow.

This clean input/output contract means a Sub Flow behaves like a proper, reusable building block rather than a copied-and-pasted fragment of your main flow.

Why Use Sub Flows?

As screen flows grow, they become harder to read, maintain, and debug. Sub Flows solve this by letting you introduce real separation between logical steps, shrinking the footprint of any single flow in the Designer and making the overall structure easier to reason about.

We strongly recommend using Sub Flows when either of the following is true:

  • Your flow contains more than 10 screens. Breaking a large flow into named, purpose-driven Sub Flows dramatically improves readability and maintainability.
  • You have a repeating process. Any sequence of steps you need to run more than once, within a single flow, or across different methods in the project, is a natural candidate for a Sub Flow. Define it once, reuse it everywhere, and update it in a single place.

The result is smaller, cleaner flows in the Designer, less duplication, and a project that scales with your business logic instead of against it.


How to Use a Sub Flow

Creating a Sub Flow is straightforward: define a new method that implements only a portion of your overall screen flow, then invoke it from wherever you need that logic.

For example, consider a business process made up of the following steps:

Login & navigate to menu screen  ->  User lookup  ->  Action on user  ->  Confirmation

Rather than modeling this as one long, monolithic flow, you can extract the reusable segments into their own Sub Flows:

  • Create a userLookup Sub Flow that encapsulates the user lookup logic, accepting the search criteria as input and returning the located user as output.
  • Create an actionOnUser Sub Flow that performs the action against a given user, accepting the target user as input and returning the operation result.
  • Invoke both Sub Flows from your main flow, wiring their inputs and outputs into the surrounding steps.

Because each Sub Flow is reusable, the same userLookup and actionOnUser logic can now be called from any other flow or method in the project that needs it. No duplication required.

Recommended workflow

  • Identify a self-contained segment of your flow (a repeating process, or a logical stage such as lookup or confirmation).
  • Create a new method to hold that segment as a Sub Flow.
  • Define the Sub Flow's input parameters and output values.
  • Implement the flow logic, using local variables as needed.
  • Call the Sub Flow from your main flow, passing the required inputs and consuming its outputs.


Did this page help you?