Workflow-Task: Edit Pre- and Postconditions
Overwrite the Pre- and Postconditions based on the provided JSON definition
Designation
- Name
- mc.WorkflowTaskModifyConditions
- Aliases
- WorkflowModifyTaskConditions
Configuration
- Optionen
- Test mode (
test-mode) - Activates a simulation mode
- Input Mode (
conditions-input-mode) - Determines whether conditions are provided via a JSON file or direct JSON text
Valid values
File (file), Text (text)
- File (
conditions-file) - File with the JSON definition
- Text (
conditions-text) - Text with the JSON definition
- Task (
task) - Name of the workflow task
- Task number (
task-no) - Running number of the workflow task
Description
This module lets you edit the preconditions and postconditions of tasks in workflows. Input is provided as a JSON file or as free text.
The JSON contains two lists:
preconditions: checked before the task startspostconditions: checked after the task ends
The following applies to both lists:
| Value | Effect |
|---|---|
null | Existing entries remain unchanged |
[] (empty list) | Existing entries are deleted |
| List with entries | Existing entries are replaced by the new ones |
Text Mode Limitations
Text mode (--conditions-input-mode text) is intended for short definitions and testing and only works reliably in the graphical user interface.
When started from the command line, problems may occur, e.g. due to special characters, spaces or very long input. Use file mode there instead:
--conditions-input-mode file --conditions-file <path to JSON file>
Entry Structure
Each entry is either a condition or an action.
{
"type": "UserDefinedCondition",
"active": true,
"once": false,
"params": { "value1": "&ENV#", "operator": "=", "value2": "PROD" },
"ifTrue": [],
"ifFalse": []
}
| Field | Description |
|---|---|
type | Name of the condition or action (see Available Conditions and Actions) |
active | true: entry is active, false: entry is deactivated |
once | true: entry is executed only once |
params | Settings of the entry (see Settings per Entry) |
ifTrue | Entries executed if the condition is met (conditions only) |
ifFalse | Entries executed if the condition is not met (conditions only) |
Nesting with ifTrue and ifFalse
ifTrue and ifFalse can contain both actions and further conditions. This allows you to build if-then-else logic of any depth (see Examples).
Precondition or Postcondition
Not every condition or action is allowed in both sections. The table Available Conditions and Actions shows where each one is permitted. If an entry is used in the wrong section, the module returns an error message.
Error Handling
If a setting in params cannot be applied, the module returns an error message. It lists all settings available for this entry. Common causes:
- The setting name is misspelled. Example:
valueOneinstead ofvalue1 - The value has the wrong format. Example:
1900instead ofENDED_OK - The value is not allowed. Example: an operator that is not in the list
Available Conditions and Actions
These names can be used as type:
| Conditions | Checks … | Pre | Post |
|---|---|---|---|
CheckActivitiesCondition | number of running activities of an object | ✓ | ✓ |
CheckConnectionCondition | whether a connection is reachable | ✓ | ✓ |
CheckFileCondition | whether a file exists | ✓ | ✓ |
CheckHistoryCondition | whether an object ended with a given status | ✓ | ✓ |
CheckProcessCondition | whether a process is running | ✓ | ✓ |
CurrentQueueCondition | which queue the task is running in | ✓ | ✓ |
CurrentTimeCondition | the current time | ✓ | ✓ |
ReturnCodeCondition | the return code of the task | – | ✓ |
StatusCondition | the end status of the task | – | ✓ |
TimeSinceActivationCondition | the time since the task was started | ✓ | ✓ |
UserDefinedCondition | two freely definable values, e.g. variables | ✓ | ✓ |
| Actions | Does … | Pre | Post |
|---|---|---|---|
AbortAction | abort the task | – | ✓ |
BlockAction | block the workflow | ✓ | ✓ |
CancelProcessFlowAction | cancel the workflow | ✓ | ✓ |
ChangeQueueAction | change the task's queue | ✓ | – |
ClearVariableAction | delete entries of a variable object | ✓ | ✓ |
ExecuteObjectAction | start another object | ✓ | ✓ |
ModifyStateAction | change the task's end status | – | ✓ |
PublishValueAction | publish a value in the workflow | ✓ | ✓ |
ReEvaluateAtAction | re-evaluate at a specific time | ✓ | – |
ReEvaluateInAction | re-evaluate after a waiting time | ✓ | – |
RestartTaskAction | restart the task | – | ✓ |
RollbackAction | perform a rollback | – | ✓ |
RunTaskAction | start the task | ✓ | – |
SetValueAction | set the value of a variable | ✓ | ✓ |
SetVariableAction | write a value to a variable object | ✓ | ✓ |
SkipTaskAction | skip the task | ✓ | – |
Settings per Entry
Value Types
The tables below show which type of value each setting expects:
| Value type | How to specify | Example |
|---|---|---|
| Text | in quotation marks | "&ENV#" |
| Number | integer, with or without quotation marks | 0 or "0" |
| Boolean | true or false | true |
| Object name | name of the object as text | "JOBS.WIN.TEST" |
| Agent | name of the agent as text | "WIN01" |
| Alias | alias as text | "MY_ALIAS" |
| Time | text in the format HH:MM, HH:MM:SS or HHMM | "06:30" |
| Status | status value, exactly in uppercase (see Status Values) | "ENDED_OK" |
| Enum | one of the listed values, case-insensitive | "BEFORE" |
| Parameter list | name/value pairs, values as text | { "&PARAM#": "1" } |
Important:
- Always put text in quotation marks.
- Write status values exactly in uppercase. An incorrect spelling (e.g.
"ended_ok") is not reported as an error but is accepted as is and then does not work as expected. - The value
nullclears a setting.nullis not allowed for Number and Boolean. - Allowed comparison operators:
=,<>,<,<=,>,>=
Conditions
CheckActivitiesCondition
Checks how many activities of an object have a specific status.
| Setting | Value type | Description |
|---|---|---|
name | Object name | Object whose activities are checked |
operator | Text | Comparison operator |
count | Number | Number to compare with |
status | Status | Status of the activities |
CheckConnectionCondition
Checks whether a connection is reachable.
| Setting | Value type | Description |
|---|---|---|
agent | Agent | Agent from which the check is made |
connection | Object name | Connection object |
The "own agent" option cannot be set via this module.
CheckFileCondition
Checks whether a file exists or does not exist.
| Setting | Value type | Description |
|---|---|---|
agent | Agent | Agent on which the file is checked |
file | Text | Path and name of the file |
exists | Boolean | true: file must exist, false: file must not exist |
login | Object name | Login object used for access |
The "own agent" and "own login" options cannot be set via this module.
CheckHistoryCondition
Checks whether an object ended with a specific status within a time period.
| Setting | Value type | Description |
|---|---|---|
name | Object name | Object to check |
status | Status | Expected end status |
dayOffset | Number | Number of days back |
timeOffset | Time | Time from which the check starts |
CheckProcessCondition
Checks whether a process is running on an agent.
| Setting | Value type | Description |
|---|---|---|
agent | Agent | Agent on which the check is made |
login | Object name | Login object |
processName | Text | Name of the process |
status | Enum | RUNNING, NOT_RUNNING |
CurrentQueueCondition
Checks whether the task is running in a specific queue.
| Setting | Value type | Description |
|---|---|---|
queueName | Object name | Queue |
CurrentTimeCondition
Checks whether the current time is before or after a given time.
| Setting | Value type | Description |
|---|---|---|
when | Enum | BEFORE, AFTER |
time | Time | Comparison time |
ReturnCodeCondition
Checks the return code of the task. Postcondition only.
| Setting | Value type | Description |
|---|---|---|
operator | Text | Comparison operator |
returnCode | Number | Return code to compare with |
StatusCondition
Checks the end status of the task. Postcondition only.
| Setting | Value type | Description |
|---|---|---|
status | Status | End status |
TimeSinceActivationCondition
Checks how long the task has been active.
| Setting | Value type | Description |
|---|---|---|
operator | Enum | MORE_THAN, LESS_THAN |
time | Time | Time span, e.g. "01:30" for 1.5 hours |
Note: This condition does not use a comparison operator such as >, but MORE_THAN or LESS_THAN.
UserDefinedCondition
Compares two freely definable values, e.g. variables.
| Setting | Value type | Description |
|---|---|---|
value1 | Text | First value |
operator | Text | Comparison operator |
value2 | Text | Second value |
Actions
AbortAction
Aborts the task. Postcondition only.
| Setting | Value type | Description |
|---|---|---|
text | Text | Reason, max. 32 characters |
BlockAction
Blocks the workflow.
| Setting | Value type | Description |
|---|---|---|
text | Text | Reason, max. 32 characters |
CancelProcessFlowAction
Cancels a workflow.
| Setting | Value type | Description |
|---|---|---|
scope | Enum | OWN (own), PARENT (parent), TOP (top-level) |
recursive | Boolean | true: also cancel child tasks |
ChangeQueueAction
Changes the queue of the task. Precondition only.
| Setting | Value type | Description |
|---|---|---|
queue | Object name | New queue |
ClearVariableAction
Deletes one entry or all entries of a variable object (VARA).
| Setting | Value type | Description |
|---|---|---|
variableName | Object name | Variable object |
key | Text | Entry to delete |
ExecuteObjectAction
Starts another object.
| Setting | Value type | Description |
|---|---|---|
name | Object name | Object to start |
wait | Boolean | true: wait for the object to end |
parameter | Parameter list | Parameters as key/value pairs (e.g. {"&PARAM1#": "Value"}) |
alias | Alias | Alias used for the start |
ModifyStateAction
Changes the end status of the task. Postcondition only.
| Setting | Value type | Description |
|---|---|---|
retCode | Number | New return code |
text | Text | Reason |
PublishValueAction
Publishes a value as a variable in the workflow.
| Setting | Value type | Description |
|---|---|---|
value | Text | Value |
publishName | Text | Name of the variable |
ReEvaluateAtAction
Re-evaluates the conditions at a specific time. Precondition only.
| Setting | Value type | Description |
|---|---|---|
days | Number | Days in the future, 0 to 99 |
time | Time | Time |
ReEvaluateInAction
Re-evaluates the conditions after a waiting time. Precondition only.
| Setting | Value type | Description |
|---|---|---|
minutes | Number | Waiting time in minutes |
RestartTaskAction
Restarts the task after a waiting time. Postcondition only.
| Setting | Value type | Description |
|---|---|---|
minutes | Number | Waiting time in minutes |
RollbackAction
Performs a rollback. Postcondition only.
| Setting | Value type | Description |
|---|---|---|
task | Enum | THIS (this task), PARENT (parent), TOP (top-level) |
Note: Always specify the value exactly in uppercase. Other spellings may be accepted as is and then not work.
RunTaskAction
Starts the task. Precondition only. Has no settings; omit params.
SetValueAction
Sets the value of a script variable.
| Setting | Value type | Description |
|---|---|---|
name | Text | Name of the variable. A leading & is removed. Must not be empty and must not start with $ |
value | Text | Value |
scope | Enum | TASK (task), PROCESS_FLOW (workflow), PARENT_PROCESS_FLOW (parent workflow) |
SetVariableAction
Writes a value to a variable object (VARA).
| Setting | Value type | Description |
|---|---|---|
variableName | Object name | Variable object |
key | Text | Entry |
valueColumn | Number | Value column, 1 to 5 |
value | Text | Value |
SkipTaskAction
Skips the task. Precondition only.
| Setting | Value type | Description |
|---|---|---|
text | Text | Reason |
Status Values
Allowed values for all settings of value type "Status":
| Group | Values |
|---|---|
ANY_* | ANY_ABEND, ANY_ABEND_EXCEPT_FAULT, ANY_ACTIVE, ANY_BLOCKED, ANY_BLOCKED_OR_STOPPED, ANY_EXCEPT_FAULT, ANY_OK, ANY_OK_OR_UNBLOCKED, ANY_SKIPPED, ANY_STOPPED, ANY_WAITING |
ENDED_* | ENDED_CANCEL, ENDED_EMPTY, ENDED_ESCALATED, ENDED_INACTIVE, ENDED_INACTIVE_MANUAL, ENDED_NOT_OK, ENDED_NOT_OK_SYNC, ENDED_OK, ENDED_OK_OR_EMPTY, ENDED_OK_OR_INACTIVE, ENDED_OK_OR_UNBLOCKED, ENDED_SKIPPED, ENDED_SKIPPED_CONDITIONS, ENDED_SKIPPED_SYNC, ENDED_TIMEOUT, ENDED_TRUNCATE, ENDED_UNDEFINED, ENDED_VANISHED |
FAULT_* | FAULT_ALREADY_RUNNING, FAULT_NO_HOST, FAULT_OTHER |
USER_* | USER_100_200, USER_147, USER_201_299, USER_300, USER_510, USER_690 |
WAITING_* | WAITING_AGENT, WAITING_AGENT_OR_AGENTGROUP, WAITING_AGENTGROUP, WAITING_EXTERNAL, WAITING_GROUP, WAITING_QUEUE, WAITING_SYNC |
Examples
Precondition: Check a File
If the file exists, the task is started. Otherwise, the check is repeated after 10 minutes.
{
"preconditions": [
{
"type": "CheckFileCondition",
"params": { "agent": "WIN01", "file": "C:\\data\\import.csv", "exists": true },
"ifTrue": [
{ "type": "RunTaskAction" }
],
"ifFalse": [
{ "type": "ReEvaluateInAction", "params": { "minutes": 10 } }
]
}
],
"postconditions": null
}
Postcondition: Evaluate Return Code and Status
If the return code is 0, an entry is written to a variable object. Otherwise, the task is restarted after 5 minutes if the status is ENDED_NOT_OK, and aborted for any other status.
{
"preconditions": null,
"postconditions": [
{
"type": "ReturnCodeCondition",
"params": { "operator": "=", "returnCode": 0 },
"ifTrue": [
{
"type": "SetVariableAction",
"params": { "variableName": "VARA.STATUS", "key": "LAST_RUN", "valueColumn": 1, "value": "OK" }
}
],
"ifFalse": [
{
"type": "StatusCondition",
"once": true,
"params": { "status": "ENDED_NOT_OK" },
"ifTrue": [
{ "type": "RestartTaskAction", "params": { "minutes": 5 } }
],
"ifFalse": [
{ "type": "AbortAction", "params": { "text": "Unexpected status" } }
]
}
]
}
]
}
Combined Preconditions and Postconditions
Before the start, the module checks whether the object is already running. After a successful end, a follow-up object is started with parameters.
{
"preconditions": [
{
"type": "CheckActivitiesCondition",
"params": { "name": "JOBS.WIN.IMPORT", "operator": ">", "count": 0, "status": "ANY_ACTIVE" },
"ifTrue": [
{ "type": "ReEvaluateInAction", "params": { "minutes": 5 } }
],
"ifFalse": [
{ "type": "RunTaskAction" }
]
}
],
"postconditions": [
{
"type": "StatusCondition",
"params": { "status": "ENDED_OK" },
"ifTrue": [
{
"type": "ExecuteObjectAction",
"params": {
"name": "JOBS.WIN.REPORT",
"wait": false,
"parameter": { "&DATE#": "&$DATE_YYYYMMDD#" }
}
}
]
}
]
}