Skip to main content

Terminate

The Terminate task is used to terminate the current workflow with a specified termination status and reason, and optionally modify the workflow output.

It can act as a return statement when you want to end a workflow without executing subsequent tasks. For example, you can execute certain tasks only when a condition is met and terminate the workflow otherwise.

Task parameters

Configure these parameters for the Terminate task.

ParameterDescriptionRequired/ Optional
inputParameters. terminationStatusThe termination status for the current workflow. Supported values:
  • COMPLETED
  • FAILED
  • TERMINATED
Required.
inputParameters. terminationReasonThe reason for terminating the current workflow, which will provide the context of the termination. It can be passed as a dynamic variable.Optional.
inputParameters. workflowOutputA map of the expected workflow output on termination. It can contain a string, number, boolean, null, or object/array.Optional.

Task configuration

This is the task configuration for a Terminate task.

{
"name": "terminate",
"taskReferenceName": "terminate_ref",
"inputParameters": {
"terminationStatus": "TERMINATED",
"workflowOutput": {
"someKey": "someValue"
},
"terminationReason": "Terminated due to xxxxxxxx."
},
"type": "TERMINATE"
}

Task output

The Terminate task will return the following parameters.

ParameterDescription
outputA map containing the workflow output defined in inputParameters.workflowOutput. If workflowOutput is not set in the Terminate task definition, the output will be an empty object.

Adding a Terminate task in UI

To add a Terminate task:

  1. In your workflow, select the (+) icon and add a Terminate task.
  2. Select the Termination status.
  3. Enter the Termination reason.
  4. (Optional) Add the Workflow output.

Adding wait task

Examples

Here are some examples for using the Terminate task.

Terminate a workflow for unsupported input

In this example, a shipping workflow selects a provider based on runtime input. If the input does not match a supported provider, the workflow terminates immediately using a Terminate task and returns an error in the workflow output.

To create a workflow:

  1. Go to Definitions > Workflow, from the left navigation menu on your Conductor cluster.
  2. Select + Define workflow.
  3. In the Code tab, paste the following workflow definition:
{
"name": "shipping-workflow",
"description": "Terminate workflow when shipping provider is unsupported",
"version": 1,
"tasks": [
{
"name": "validate_provider",
"taskReferenceName": "validate_provider_ref",
"inputParameters": {
"shippingProvider": "${workflow.input.shippingProvider}"
},
"type": "SWITCH",
"decisionCases": {
"fedex": [
{
"name": "process_fedex",
"taskReferenceName": "process_fedex_ref",
"inputParameters": {},
"type": "SIMPLE"
}
],
"dhl": [
{
"name": "process_dhl",
"taskReferenceName": "process_dhl_ref",
"inputParameters": {},
"type": "SIMPLE"
}
]
},
"defaultCase": [
{
"name": "terminate_workflow",
"taskReferenceName": "terminate_workflow_ref",
"inputParameters": {
"terminationStatus": "FAILED",
"terminationReason": "Unsupported shipping provider",
"workflowOutput": {
"error": "The specified shipping provider is not supported."
}
},
"type": "TERMINATE"
}
],
"evaluatorType": "value-param",
"expression": "shippingProvider"
}
],
"inputParameters": [
"shippingProvider"
],
"schemaVersion": 2
}
  1. Select Save > Confirm.

This workflow supports only two shipping providers: fedex and dhl. If any other value is provided at runtime, the Switch task executes the default case and terminates the workflow using the Terminate task.

To run the workflow:

  1. Go to the Run tab, and enter the Input params. For example:
{
"shippingProvider": "ups"
}
  1. Select Execute.

This executes the workflow, and because ups is not a supported value, the workflow is terminated using the Terminate task.

Terminate Example