Dynamic
The Dynamic task executes a registered task dynamically at runtime. It is similar to a function pointer in programming and can be used in cases where the decision to execute a task will only be made after the workflow has begun. Unlike the Switch task, the Dynamic task offers flexibility without requiring updates to the workflow definition.
The Dynamic task accepts as input the name of a task, which can be a system task, a sub-workflow, or a custom Worker task registered on Conductor.
Task parameters
Configure these parameters for the Dynamic task.
| Parameter | Description | Required/ Optional |
|---|---|---|
| dynamicTaskNameParam | The input parameter key whose value is used to schedule the task. For example, "taskToExecute", which will then be specified as an input parameter in the Dynamic task. | Required. |
| inputParameters. taskToExecute | The name of the task that will be executed. It can be passed as a dynamic variable. | Required. |
| inputParameters | Contains the inputs to the task that will be executed. | Required, depending on the task. |
The following are generic configuration parameters that can be applied to the task and are not specific to the Dynamic task.
Other generic parameters
Here are other parameters for configuring the task behavior.
| Parameter | Description | Required/ Optional |
|---|---|---|
| optional | Whether the task is optional. If set to true, any task failure is ignored, and the workflow continues with the task status updated to COMPLETED_WITH_ERRORS. However, the task must reach a terminal state. If the task remains incomplete, the workflow waits until it reaches a terminal state before proceeding. | Optional. |
Configuration for calling a sub-workflow
If the Dynamic task to be called is a Sub Workflow task, then taskToExecute must be set to SUB_WORKFLOW. The inputParameters for the Dynamic task should also include these fields:
- Using workflow name and version
- Using workflow definition JSON
// Dynamic task defintion
"inputParameters": {
"subWorkflowName":"someName",
"subworkflowVersion": "1"
}
Using the workflow definition JSON instead of the workflow name and version is useful when the sub-workflow has not been registered in the Conductor server beforehand. This option is ideal for constructing dynamic sub-workflows on the fly.
// Dynamic task definition
"inputParameters": {
"subWorkflowDefinition":{ //subworkflow JSON definition}
}
Task configuration
This is the task configuration for a Dynamic task.
- All tasks
- Sub-workflows
{
"name": "dynamic",
"taskReferenceName": "dynamic_ref",
"inputParameters": {
"taskToExecute": "${workflow.input.dynamicTaskName}" // name of the task to execute
},
"type": "DYNAMIC",
"dynamicTaskNameParam": "taskToExecute" // input parameter key that will hold the task name to execute
}
{
"name": "dynamic",
"taskReferenceName": "dynamic_ref",
"inputParameters": {
"taskToExecute": "SUB_WORKFLOW",
"subWorkflowName": "${workflow.input.someName}", // the name of the sub-workflow to execute
"subWorkflowVersion": "1"
},
"type": "DYNAMIC",
"dynamicTaskNameParam": "taskToExecute"
}
Task output
During execution, the Dynamic task is replaced with whatever task that is called at runtime. The output of the Dynamic task will be whatever the output of the called task is.
Adding a Dynamic task in UI
To add a Dynamic task:
- In your workflow, select the (+) icon and add a Dynamic task.
- In Task input params, specify the task to execute by setting a value in the
taskToExecuteparameter. The value can be passed as a dynamic variable (for example,${workflow.input.dynamicTaskName}).

Examples
Here are some examples for using the Dynamic task.
Using the Dynamic task in a workflow
A Dynamic task executes a task type at runtime based on an input value. This example builds a workflow that dynamically executes the HTTP system task.
To create a workflow:
- Go to Definitions > Workflow, from the left navigation menu on your Conductor cluster.
- Select + Define workflow.
- In the Code tab, paste the following workflow definition:
{
"name": "Dynamic_HTTP_Demo",
"description": "Dynamically executes the HTTP system task using a Dynamic task.",
"version": 1,
"schemaVersion": 2,
"inputParameters": [
"taskType"
],
"tasks": [
{
"name": "dynamic_http_task",
"taskReferenceName": "dynamic_http_task_ref",
"type": "DYNAMIC",
"inputParameters": {
"taskToExecute": "${workflow.input.taskType}",
"uri": "https://orkes-api-tester.orkesconductor.com/api",
"method": "GET",
"accept": "application/json",
"contentType": "application/json",
"encode": true
},
"dynamicTaskNameParam": "taskToExecute"
}
]
}
- Select Save > Confirm.
To run the workflow:
- Go to the Run tab, and enter the Input params. For example:
{
"taskType": "HTTP"
}
- Select Execute.
This takes you to the workflow execution page. You can verify that:
- The Dynamic task is replaced at runtime with the HTTP task.
- The HTTP task completes successfully.
- The task output contains the HTTP response.

Using the Dynamic task to execute a sub-workflow
A Dynamic task can execute a sub-workflow at runtime when the sub-workflow name is determined after the workflow starts. This example builds a parent workflow that executes a sub-workflow dynamically using the SUB_WORKFLOW task type.
Before you begin, create the workflows to be called as Sub Workflows.
To create a workflow:
- Go to Definitions > Workflow, from the left navigation menu on your Conductor cluster.
- Select + Define workflow.
- In the Code tab, paste the following workflow definition:
{
"name": "ship_via_fedex",
"description": "Sub-workflow that simulates FedEx shipping.",
"version": 1,
"schemaVersion": 2,
"tasks": [
{
"name": "fedex_http",
"taskReferenceName": "fedex_http_ref",
"type": "HTTP",
"inputParameters": {
"uri": "https://orkes-api-tester.orkesconductor.com/api",
"method": "GET",
"accept": "application/json",
"contentType": "application/json",
"encode": true
}
}
]
}
- Select Save > Confirm.
Repeat the steps and create another workflow for UPS using the following code:
{
"name": "ship_via_ups",
"description": "Sub-workflow that simulates UPS shipping.",
"version": 1,
"schemaVersion": 2,
"tasks": [
{
"name": "ups_http",
"taskReferenceName": "ups_http_ref",
"type": "HTTP",
"inputParameters": {
"uri": "https://orkes-api-tester.orkesconductor.com/api",
"method": "GET",
"accept": "application/json",
"contentType": "application/json",
"encode": true
}
}
]
}
Next, create the parent workflow that includes a Dynamic task, which will call any of these workflows.
{
"name": "Dynamic_Subworkflow_Demo",
"description": "Dynamically executes a sub-workflow based on runtime input.",
"version": 1,
"schemaVersion": 2,
"inputParameters": [
"carrierWorkflow"
],
"tasks": [
{
"name": "dynamic_subworkflow",
"taskReferenceName": "dynamic_subworkflow_ref",
"type": "DYNAMIC",
"inputParameters": {
"taskToExecute": "SUB_WORKFLOW",
"subWorkflowName": "${workflow.input.carrierWorkflow}",
"subworkflowVersion": 1
},
"dynamicTaskNameParam": "taskToExecute"
}
]
}
In this workflow, the Dynamic task schedules a sub-workflow by setting taskToExecute to SUB_WORKFLOW and providing the sub-workflow name as input.
To run the workflow:
- Go to the Run tab, and enter the Input params. For example:
{
"carrierWorkflow": "ship_via_fedex"
}
- Select Execute.
This takes you to the workflow execution page. You can verify that:
- The Dynamic task is replaced at runtime with a sub-workflow execution.
- The executed sub-workflow name matches the value passed in
carrierWorkflow.

- The sub-workflow’s HTTP task completes successfully.
