Sub Workflow Task
"type" : "SUB_WORKFLOW"
Sub Workflow task allows for nesting a workflow within another workflow.
You can leverage sub-workflow tasks in cases where you want to include another workflow within an existing workflow.
Do-Whiletask does not allow nested
Do-Whiletasks. But it does permit a sub-workflow that can have a
Do-Whileloop inside it.
Dynamic Forkscan only contain one task. But using the sub-workflow concept, this single task can be a sub-workflow that includes additional tasks.
Sub Workflow task is defined directly inside the workflow with
|subWorkflowParam||Map[String, Any]||It includes the parameters name, version, taskToDomain & workflowDefinition. See the below table for detailed info on this.|
|inputParameters||Map[String, Any]||The sub workflow’s input can be coupled to the workflow’s input parameters or it can be invoked from the output of the preceding task. For example, if you are taking the sub-workflow’s input parameter from the workflow, then you need to initially add this as an input parameter in the parent workflow (workflow to be called as the sub-workflow). Then you can call the same input parameter inside the sub-workflow definition.|
|name||String||You need to map this field with the name of the workflow you are planning to execute.|
|version||Integer||Include the version of the workflow to be executed.|
|taskToDomain||Map[String, String]||Allows scheduling the sub-workflow's tasks per given mappings. See Task Configurations for instructions to configure taskDomains.|
|workflowDefinition||WorkflowDefinition||Allows starting a sub-workflow with a dynamic workflow definition.|
|subWorkflowId||String||Subworkflow execution ID generated when running the sub-workflow|
The output of the sub-workflow is also supplied to the output of the workflow.
Imagine that a colleague has created an address verification workflow:
If you wanted to add this functionality to another workflow, it would be possible to copy all 201 lines of JSON and insert them into your workflow. However, any updates made by your colleague will not be reflected in your workflow, i.e., you have a "frozen in time" version of the code.
Instead, you can call the existing workflow as a
This not only makes your workflow more readable, with easier-to-edit JSON, but it will update with the
Visualize an example workflow Order Fulfillment, where a sub-workflow is being called within a dynamic fork.