Teneo Developers

Sub-flows

Parent Flows and Sub-flows

Sub-flows are, unlike parent Flows, not triggered by user input. Actually, Sub-flows do not have triggers at all; Sub-flows are activated using Flow Link nodes in parent Flows which then refers to the Sub-flow.

Once the Sub-flow has run, execution will be handed back to the parent Flow. One Flow can have multiple Flow Links to Sub-flows, which will behave as if they were part of the parent Flow.

The idea is that a Sub-flow can be called from different Flows in a solution, so there can be several active instances of a single Sub-flow, one per active parent Flow that uses the Sub-flow. This means that the state of each of those Sub-flows can be different in each of those active instances. Parent Flows, however, can only have one active instance at a time.

Sub-flows can be used for many different purposes; for example, one Sub-flow can be used to find out the user's first and last name, and then invoke that Sub-flow from different parent Flows where that information is required.

Another example could be when integrating external services; although the integration manager would normally be used for that, a Sub-flow containing the integration script could also be used, which could be invoked from different parent flows when necessary.

Sub-flows versus regular Flows

When a Flow Link node is pointing to a Sub-flow, the currently active parent Flow will still be the active Flow after the Sub-flow is executed; that is to say: the parent Flow is executed first, up to the Flow Link node, then the Sub-flow runs and, when completed, returns control to the parent Flow to continue execution.

However, if a flow link is added to another regular Flow, i.e. a Flow that has not been marked as Sub-flow, the current Parent Flow will be dropped when the Flow Link node is reached and the linked Flow is executed.

A consequence of this is that it is not possible to use return transfer variables when linking to a regular Flow. When doing this, the execution is handed over to the linked Flow, and the current Flow is terminated. This is why transfer variables cannot be returned in that case.

Of course, Sub-flows can also call other Sub-flows, there is no limit as to the number of Sub-flows that can be executed.

Linking Flows
Create a Sub-flow