You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Subworkflows

Subworkflows enable you to define reusable pieces of logic that other workflows can utilize. You can think of a subworkflow as a function from classic programming languages.

On the list of available workflows, there is an additional subworkflow inclusion filter option.

Annotated image

Execution Arguments

When calling subworkflows, 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 subworkflow.

Annotated image

Execution Results

After the subworkflow is done with its execution, the calling workflow gains access to the subworkflow’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 subworkflow. The result field identifies the variable name in the subworkflow’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 subworkflow’s state.

Annotated image

Creating Subworkflows

To create a subworkflow, 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.

Subworkflows can not utilize triggers and can not be executed like regular workflows.

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

Annotated image

The source code for the subworkflow example.

Using Subworkflows

Subworkflows 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 subworkflow), execution arguments, and execution results.

Annotated image

The source code for the workflow example.