Skip to main content
Version: Next

Workflow-Task: Edit Pre- and Postconditions

Overwrite the Pre- and Postconditions based on the provided JSON definition

Designation​

Name
mc.WorkflowTaskModifyConditions
Aliases
WorkflowModifyTaskConditions

Configuration​

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 starts
  • postconditions: checked after the task ends

The following applies to both lists:

ValueEffect
nullExisting entries remain unchanged
[] (empty list)Existing entries are deleted
List with entriesExisting 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": []
}
FieldDescription
typeName of the condition or action (see Available Conditions and Actions)
activetrue: entry is active, false: entry is deactivated
oncetrue: entry is executed only once
paramsSettings of the entry (see Settings per Entry)
ifTrueEntries executed if the condition is met (conditions only)
ifFalseEntries 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: valueOne instead of value1
  • The value has the wrong format. Example: 1900 instead of ENDED_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:

ConditionsChecks …PrePost
CheckActivitiesConditionnumber of running activities of an object✓✓
CheckConnectionConditionwhether a connection is reachable✓✓
CheckFileConditionwhether a file exists✓✓
CheckHistoryConditionwhether an object ended with a given status✓✓
CheckProcessConditionwhether a process is running✓✓
CurrentQueueConditionwhich queue the task is running in✓✓
CurrentTimeConditionthe current time✓✓
ReturnCodeConditionthe return code of the task–✓
StatusConditionthe end status of the task–✓
TimeSinceActivationConditionthe time since the task was started✓✓
UserDefinedConditiontwo freely definable values, e.g. variables✓✓
ActionsDoes …PrePost
AbortActionabort the task–✓
BlockActionblock the workflow✓✓
CancelProcessFlowActioncancel the workflow✓✓
ChangeQueueActionchange the task's queue✓–
ClearVariableActiondelete entries of a variable object✓✓
ExecuteObjectActionstart another object✓✓
ModifyStateActionchange the task's end status–✓
PublishValueActionpublish a value in the workflow✓✓
ReEvaluateAtActionre-evaluate at a specific time✓–
ReEvaluateInActionre-evaluate after a waiting time✓–
RestartTaskActionrestart the task–✓
RollbackActionperform a rollback–✓
RunTaskActionstart the task✓–
SetValueActionset the value of a variable✓✓
SetVariableActionwrite a value to a variable object✓✓
SkipTaskActionskip the task✓–

Settings per Entry​

Value Types​

The tables below show which type of value each setting expects:

Value typeHow to specifyExample
Textin quotation marks"&ENV#"
Numberinteger, with or without quotation marks0 or "0"
Booleantrue or falsetrue
Object namename of the object as text"JOBS.WIN.TEST"
Agentname of the agent as text"WIN01"
Aliasalias as text"MY_ALIAS"
Timetext in the format HH:MM, HH:MM:SS or HHMM"06:30"
Statusstatus value, exactly in uppercase (see Status Values)"ENDED_OK"
Enumone of the listed values, case-insensitive"BEFORE"
Parameter listname/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 null clears a setting. null is not allowed for Number and Boolean.
  • Allowed comparison operators: =, <>, <, <=, >, >=

Conditions​

CheckActivitiesCondition​

Checks how many activities of an object have a specific status.

SettingValue typeDescription
nameObject nameObject whose activities are checked
operatorTextComparison operator
countNumberNumber to compare with
statusStatusStatus of the activities

CheckConnectionCondition​

Checks whether a connection is reachable.

SettingValue typeDescription
agentAgentAgent from which the check is made
connectionObject nameConnection object

The "own agent" option cannot be set via this module.

CheckFileCondition​

Checks whether a file exists or does not exist.

SettingValue typeDescription
agentAgentAgent on which the file is checked
fileTextPath and name of the file
existsBooleantrue: file must exist, false: file must not exist
loginObject nameLogin 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.

SettingValue typeDescription
nameObject nameObject to check
statusStatusExpected end status
dayOffsetNumberNumber of days back
timeOffsetTimeTime from which the check starts

CheckProcessCondition​

Checks whether a process is running on an agent.

SettingValue typeDescription
agentAgentAgent on which the check is made
loginObject nameLogin object
processNameTextName of the process
statusEnumRUNNING, NOT_RUNNING

CurrentQueueCondition​

Checks whether the task is running in a specific queue.

SettingValue typeDescription
queueNameObject nameQueue

CurrentTimeCondition​

Checks whether the current time is before or after a given time.

SettingValue typeDescription
whenEnumBEFORE, AFTER
timeTimeComparison time

ReturnCodeCondition​

Checks the return code of the task. Postcondition only.

SettingValue typeDescription
operatorTextComparison operator
returnCodeNumberReturn code to compare with

StatusCondition​

Checks the end status of the task. Postcondition only.

SettingValue typeDescription
statusStatusEnd status

TimeSinceActivationCondition​

Checks how long the task has been active.

SettingValue typeDescription
operatorEnumMORE_THAN, LESS_THAN
timeTimeTime 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.

SettingValue typeDescription
value1TextFirst value
operatorTextComparison operator
value2TextSecond value

Actions​

AbortAction​

Aborts the task. Postcondition only.

SettingValue typeDescription
textTextReason, max. 32 characters

BlockAction​

Blocks the workflow.

SettingValue typeDescription
textTextReason, max. 32 characters

CancelProcessFlowAction​

Cancels a workflow.

SettingValue typeDescription
scopeEnumOWN (own), PARENT (parent), TOP (top-level)
recursiveBooleantrue: also cancel child tasks

ChangeQueueAction​

Changes the queue of the task. Precondition only.

SettingValue typeDescription
queueObject nameNew queue

ClearVariableAction​

Deletes one entry or all entries of a variable object (VARA).

SettingValue typeDescription
variableNameObject nameVariable object
keyTextEntry to delete

ExecuteObjectAction​

Starts another object.

SettingValue typeDescription
nameObject nameObject to start
waitBooleantrue: wait for the object to end
parameterParameter listParameters as key/value pairs (e.g. {"&PARAM1#": "Value"})
aliasAliasAlias used for the start

ModifyStateAction​

Changes the end status of the task. Postcondition only.

SettingValue typeDescription
retCodeNumberNew return code
textTextReason

PublishValueAction​

Publishes a value as a variable in the workflow.

SettingValue typeDescription
valueTextValue
publishNameTextName of the variable

ReEvaluateAtAction​

Re-evaluates the conditions at a specific time. Precondition only.

SettingValue typeDescription
daysNumberDays in the future, 0 to 99
timeTimeTime

ReEvaluateInAction​

Re-evaluates the conditions after a waiting time. Precondition only.

SettingValue typeDescription
minutesNumberWaiting time in minutes

RestartTaskAction​

Restarts the task after a waiting time. Postcondition only.

SettingValue typeDescription
minutesNumberWaiting time in minutes

RollbackAction​

Performs a rollback. Postcondition only.

SettingValue typeDescription
taskEnumTHIS (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.

SettingValue typeDescription
nameTextName of the variable. A leading & is removed. Must not be empty and must not start with $
valueTextValue
scopeEnumTASK (task), PROCESS_FLOW (workflow), PARENT_PROCESS_FLOW (parent workflow)

SetVariableAction​

Writes a value to a variable object (VARA).

SettingValue typeDescription
variableNameObject nameVariable object
keyTextEntry
valueColumnNumberValue column, 1 to 5
valueTextValue

SkipTaskAction​

Skips the task. Precondition only.

SettingValue typeDescription
textTextReason

Status Values​

Allowed values for all settings of value type "Status":

GroupValues
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#" }
}
}
]
}
]
}