Skip to main content
Version: ACE 5

Condition

Overview

Condition is a step which allows execution of other steps by evaluating expressions of one or many case conditions, as well as a defaulting case when there are no matches.

Condition step is similar to switch step, but instead is based on if...else statements.

Execution

When the condition step is executed, it will evalute expressions of ony or many case conditions. Once the first case is matched, it (meaning the steps contained within the case) will be executed. If no case is matched, the default case will be executed instead.

It is possible to nest condition steps multiple levels.

Configuration

  • cases - array of condition cases, each case contains a condition and also a steps array
    • condition - case condition (e.g {{value === 35}}) which will be evaluated as truthy value.
    • steps - array of steps to sequentially execute if the case is matched
  • defaultCase - array of steps to sequentially execute if no cases match, can be empty

Sample step configuration

Sample step
name: Step condition
description: ""
stepType: condition
config: {}
cases:
- condition: '{{value === "house"}}'
steps:
- name: Step jsonata
description: ""
config:
maps:
- jsonata: '{"message": "house was selected"}'
targetPath: result
stepType: jsonata
condition: ""
- condition: '{{value === "life"}}'
steps:
- name: Step jsonata
description: ""
config:
maps:
- jsonata: '{"message": "life was selected"}'
targetPath: result
stepType: jsonata
condition: ""
defaultCase:
- name: Step jsonata
description: ""
config:
maps:
- jsonata: '{"message": "else step was selected"}'
targetPath: result
stepType: jsonata
condition: ""

Examples

Condition step used in flow to match policy types

GetMessageByCategory.yaml
tags: []
sampleInputSchema: ""
sampleData: {}
description: ""
steps:
- name: Step condition
description: ""
stepType: condition
config: {}
cases:
- condition: '{{value === "house"}}'
steps:
- name: Step jsonata
description: ""
config:
maps:
- jsonata: '{"message": "house was selected"}'
targetPath: result
stepType: jsonata
condition: ""
- condition: '{{value === "life"}}'
steps:
- name: Step jsonata
description: ""
config:
maps:
- jsonata: '{"message": "life was selected"}'
targetPath: result
stepType: jsonata
condition: ""
defaultCase:
- name: Step jsonata
description: ""
config:
maps:
- jsonata: '{"message": "else step was selected"}'
targetPath: result
stepType: jsonata
condition: ""
condition: ""

Document and result for case 1

Input document
{
"value": "house"
}
Result document
{
"result": {
"message": "house was selected"
}
}

Document and result for case 2

Input document
{
"value": "life"
}
Result document
{
"result": {
"message": "life was selected"
}
}

Document and result for default case

Input document
{
"value": "custom"
}
Result document
{
"result": {
"message": "else step was selected"
}
}