Skip to main content

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 configuration

Configure these parameters for the Terminate Workflow task.

ParameterDescriptionRequired/ Optional
inputParameters. workflowIdAn array of one or more workflow IDs of the workflow executions to be terminated. It can be passed as a variable.Required.
inputParameters. terminationReasonThe reason for terminating the workflow(s), which will provide the context of the termination. It can be passed as a variable.Optional.
triggerFailureWorkflowWhether the failure workflow for the terminated workflow will be triggered. Accepted values:
  • true—The failure workflow will be triggered.
  • false—The default option. The failure workflow will not be triggered.
Required.

Task definition

This is the JSON schema for a Terminate Workflow task definition.

{
"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.

ParameterDescription
terminatedWorkflowsAn array of the workflow IDs corresponding to the terminated workflows.

Adding a Terminate Workflow task in UI

To add a Terminate Workflow task:

  1. In your workflow, select the (+) icon and add a Terminate Workflow task.
  2. Enter the workflow IDs along with the termination reason.
  3. (Optional) Check Trigger Failure Workflow if needed.

Adding wait task

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.

Terminate Workflow - Successful execution

To verify this, go to Executions > Workflow and search for the terminated workflow ID. Select the workflow ID to view the execution.

Verifying the terminated workflow from executions

At the top of the execution details, you can view the termination reason that was provided in the Terminate Workflow task.

View of the terminated workflow

Terminate workflow with Trigger Failure Workflow enabled

In this example workflow, a failure workflow has been set up for it.

Workflow to be terminated

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)

Getting the workflow ID of the workflow to be terminated

In a separate workflow, you can terminate the above running workflow using the Terminate Workflow task.

Main workflow with 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.

Running terminate workflow demo

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.

Execution of the terminated workflow

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.

Triggered failure workflow