Sub-workflows

Sub-workflows enable you to define reusable pieces of logic that other workflows can utilize. You can think of a sub-workflow as a function from classic programming languages.

On the list of available workflows, there is an additional sub-workflow inclusion filter option.

Annotated image

Execution Arguments

When calling sub-workflows, you can pass an arbitrary execution argument encoded as a Vars data type.

Click on the cog cog icon on the exec-workflow exec workflow step and locate the "arguments" section. Any value passed in the scope argument will be available in the execution context of the sub-workflow.

Annotated image

Execution Results

After the sub-workflow is done with its execution, the calling workflow gains access to the sub-workflow’s execution scope at the state it finished.

Click on the cog cog icon on the exec-workflow exec workflow step and locate the "results" section. Specify a list of values (and the variable name) you’d like to preserve from the sub-workflow. The result field identifies the variable name in the sub-workflow’s state, and the target identifies the variable name in the caller’s state.

There is no limit to the number of values you can access from the sub-workflow’s state.

Annotated image

Creating Sub-workflows

To create a sub-workflow, navigate to the Workflow web application and create a new workflow. Tick the subworkflow checkbox when configuring the workflow metadata.

Annotated image

Configure the rest of the workflow as you would with any other workflow. Refer to main workflow documentation for details.

Sub-workflows can not utilize triggers and can not be executed like regular workflows.

The following example defines a simple sub-workflow where we log the received value and then prepare a new value for the calling workflow.

Annotated image

The source code for the sub-workflow example.

Using Sub-workflows

Sub-workflows are called from regular workflows using the exec-workflow exec workflow step. The exec-workflow exec workflow step requires you to specify what workflow you wish to execute (must be a sub-workflow), execution arguments, and execution results.

Annotated image

The source code for the workflow example.