Skip to main content

Sub Workflow

"type" : "SUB_WORKFLOW"

Introduction

Sub Workflow task allows for nesting a workflow within another workflow.

Use Cases

Suppose we want to include another workflow inside our current workflow. In that case, Sub Workflow Task would be used.

Examples

  • The Do-While Task does not allow nested Do-While tasks. But it does permit a subworkflow that can have a Do-While loop inside it.
  • Dynamic Forks can only contain one task. But that one task can be a subworkflow containing many additional tasks.

Configuration

Sub Workflow task is defined directly inside the workflow with "SUB_WORKFLOW".

Inputs

Parameters:

nametypedescription
subWorkflowParamMap[String, Any]See below

subWorkflowParam

nametypedescription
nameStringName of the workflow to execute
versionIntegerVersion of the workflow to execute
taskToDomainMap[String, String]Allows scheduling the sub workflow's tasks per given mappings. See Task Configurations for instructions to configure taskDomains.
workflowDefinitionWorkflowDefinitionAllows starting a subworkflow with a dynamic workflow definition.

Output

nametypedescription
subWorkflowIdStringSubworkflow execution Id generated when running the subworkflow

Examples

Imagine that a colleague has created a address verification workflow:

example workflow

If you wanted to add this functionality to another workflow, it would be possible to copy all 201 lines of JSON and insert it into your workflow. However, any updates made by your colleague will not be reflected in your workflow - you have a "frozen in time" version of the code.

Instead, we can call the existing workflow as a SUB_WORKFLOW task.

{
"name": "postage_rate_subworkflow",
"taskReferenceName": "postage_rate_subworkflow_ref",
"inputParameters": {},
"type": "SUB_WORKFLOW",
"decisionCases": {},
"defaultCase": [],
"forkTasks": [],
"startDelay": 0,
"subWorkflowParam": {
"name": "shipping_rate",
"version": 1
},
"joinOn": [],
"optional": false,
"defaultExclusiveJoinTask": [],
"asyncComplete": false,
"loopOver": []
}

example workflow with subworkflow

Not only is your workflow more readable, with easier to edit JSON, but it will update with the postage_rate workflow.