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.
When calling subworkflows, you can pass an arbitrary execution argument encoded as a
Vars data type.
Click on the cog icon on the 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.
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 icon on the 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.
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.
To create a subworkflow, navigate to the Workflow web application and create a new workflow. Tick the subworkflow checkbox when configuring the workflow metadata.
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.
The source code for the subworkflow example.