Terminate Workflow
The Terminate Workflow task allows for the termination of other workflows using their workflow IDs. It allows users to terminate single or multiple workflows with optional parameters for specifying termination reasons and triggering failure workflows.
Task parameters
Configure these parameters for the Terminate Workflow task.
Parameter | Description | Required/ Optional |
---|---|---|
inputParameters. workflowId | An array of one or more workflow IDs of the workflow executions to be terminated. It can be passed as a variable. | Required. |
inputParameters. terminationReason | The reason for terminating the workflow(s), which will provide the context of the termination. It can be passed as a variable. | Optional. |
triggerFailureWorkflow | Whether the failure workflow for the terminated workflow will be triggered. Accepted values:
| Required. |
Task configuration
This is the task configuration for a Terminate Workflow task.
{
"name": "TW",
"taskReferenceName": "TW_ref",
"inputParameters": {
"workflowId": [
"someWorkflowID",
"anotherWorkflowID" // Array containing a single or multiple workflow IDs
],
"terminationReason": ""
},
"triggerFailureWorkflow": false,
"type": "TERMINATE_WORKFLOW"
}
Task output
The Terminate Workflow task will return the following parameters.
Parameter | Description |
---|---|
terminatedWorkflows | An array of the workflow IDs corresponding to the terminated workflows. |
Adding a Terminate Workflow task in UI
To add a Terminate Workflow task:
- In your workflow, select the (+) icon and add a Terminate Workflow task.
- Enter the workflow IDs along with the termination reason.
- (Optional) Check Trigger Failure Workflow if needed.
Examples
Here are some examples for using the Terminate Workflow task.
Using the Terminate Workflow task in a workflow
To demonstrate the Terminate Workflow task, consider the following sample workflow. This example shows how to configure a workflow that terminates another running workflow.
// workflow definition
{
"name": "terminate-workflow-sample-workflow",
"description": "Sample workflow to demonstrate terminate workflow task",
"version": 1,
"tasks": [
{
"name": "TW",
"taskReferenceName": "TW_ref",
"inputParameters": {
"workflowId": [
"289cf124-2240-11ef-8b99-ae209b03ac3f"
],
"terminationReason": "The workflow is terminated due to xxxxxxxxxxx."
},
"type": "TERMINATE_WORKFLOW"
}
]
}
Upon running the workflow, the workflow execution with the specified ID 289cf124-2240-11ef-8b99-ae209b03ac3f
will be terminated.
To verify this, go to Executions > Workflow and search for the terminated workflow ID. Select the workflow ID to view the execution.
At the top of the execution details, you can view the termination reason that was provided in the Terminate Workflow task.
Terminate workflow with Trigger Failure Workflow enabled
In this example workflow, a failure workflow has been set up for it.
This is the example workflow JSON definition, which includes the failure workflow:
// workflow definition
{
"name": "test-workflow",
"description": "test",
"version": 1,
"tasks": [
{
"name": "simple",
"taskReferenceName": "simple_ref",
"inputParameters": {},
"type": "SIMPLE"
}
],
"failureWorkflow": "failure"
}
Now, let’s run the workflow and obtain its workflow ID (example: 8c14384c-2400-11ef-ad70-52278f6d0e42)
In a separate workflow, you can terminate the above running workflow using the Terminate Workflow task.
This is the JSON definition for the second workflow:
// workflow definition
{
"name": "terminate-workflow-demo",
"description": "Sample workflow",
"version": 1,
"tasks": [
{
"name": "TW",
"taskReferenceName": "TW_ref",
"inputParameters": {
"workflowId": [
"8c14384c-2400-11ef-ad70-52278f6d0e42"
],
"terminationReason": "Workflow is terminated.",
"triggerFailureWorkflow": true
},
"type": "TERMINATE_WORKFLOW"
}
]
}
The input parameters for the Terminate Workflow task contain the following configuration:
- The above running workflow’s workflow ID is provided as an input parameter, along with a termination reason.
- The option to trigger failure workflow is enabled.
Now, let’s run this workflow.
Upon completion, the workflow with the ID 8c14384c-2400-11ef-ad70-52278f6d0e42
will be terminated. To view the execution of the terminated workflow, go to Executions > Workflow and search using the workflow ID.
At the top of the execution details, you can view the termination reason that was provided in the Terminate Workflow task and see that the failure workflow has been triggered. Select Triggered failure workflow to view the failure workflow’s execution.