CCCTC Docs

CCCTC Docs

  • Help

Status Task System Task

STATUS_TASK is a System Task that returns the given status and error message. This can be used in a DECISION tree to set affect the overall status of the workflow based on a condition.

Example

This workflow will execute the STATUS_TASK on the default case of the decision to force a FAIL status on the workflow.

{
    "name": "testWF",
    "description": "STATUS_TASK demo",
    "version": 1,
    "inputParameters": ["test-condition"],
    "tasks": [
        {
            "name": "decide_task",
            "taskReferenceName": "decision",
            "inputParameters": {
                "test-condition": "${workflow.input.test-condition}"
            },
            "type": "DECISION",
            "caseValueParam": "test-condition",
            "decisionCases": {
                "condition1": [
                    {
                        "name": "sub-workflow",
                        "taskReferenceName": "sub-workflow-1",
                        "type": "SUB_WORKFLOW",
                        "subWorkflowParam": {
                            "name": "subworkflow1WF",
                            "version": 1
                        }
                    }
                ],
                "condition2": [
                    {
                        "name": "sub-workflow",
                        "taskReferenceName": "sub-workflow-2",
                        "type": "SUB_WORKFLOW",
                        "subWorkflowParam": {
                            "name": "subworkflow2WF",
                            "version": 1
                        }
                    }
                ],
            },
            "defaultCase": [
                {
                    "name": "status-task",
                    "taskReferenceName": "unknown-condition",
                    "type": "STATUS_TASK",
                    "inputParameters": {
                        "status": "FAILED",
                        "reasonForIncompletion": "Unknown condition: ${workflow.input.test-condition}"
                    }
                }
            ]
        }
    ],
    "schemaVersion": 2
}

Other usages

This task could also be used to conditionally fail a workflow based on output from another task. To get the correct status, you could use Value Mapper to perform a switch/case to determine which values constitute an error.

Example:

  1. test-condition is checked and based on its value status will get a value of FAILED or COMPLETED
  2. test-condition is checked and based on its value reasonForIncompletion will get a value of error-message or null
{
    "name": "testWF",
    "description": "STATUS_TASK demo",
    "version": 1,
    "inputParameters": ["test-condition", "error-message"],
    "tasks": [
        {
            "name": "value-mapper",
            "taskReferenceName": "mapped",
            "type": "VALUE_MAPPER",
            "inputParameters": {
                "sources": {
                    "status": "${workflow.input.test-condition}",
                    "error": "${workflow.input.test-condition}"
                },
                "switches": [
                    {
                        "source": "status",
                        "cases": {
                            "bad-condition": "FAILED",
                            "other-bad-condition": "FAILED"
                        },
                        "defaultValue": "COMPLETED"
                    },
                    {
                        "source": "error",
                        "cases": {
                            "bad-condition": "${workflow.input.error-message}",
                            "other-bad-condition": "${workflow.input.error-message}"
                        },
                        "defaultValue": null
                    }                     
                ]
            }
        },
        {
            "name": "status-task",
            "taskReferenceName": "unknown-condition",
            "type": "STATUS_TASK",
            "inputParameters": {
                "status": "${mapped.status}",
                "reasonForIncompletion": "${mapped.error}"
            }
        }
    ],
    "schemaVersion": 2
}
  • Example
  • Other usages