Skip to main content

switch

A switch expression. If none of the defined cases match _default case is executed.

Field Configurations

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters

KeyTypeDescriptionDefault Value
"async"BooleanSpecifies whether the action should perform asynchronously.null
"cases" (required)ObjectPossible cases. Use _default to create default case.null
"value" (required)ObjectExpression that should be evaluated.null

Inherited

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples

Example: switch expression

Goal: Create switch expression to decide what to do.

Evaluate exampleValue to decide which message should be displayed.

{
"type": "switch",
"params": {
"value": {
"context": "device",
"field": "os"
},
"cases": {
"android": [
{
"type": "showMessage",
"params": {
"text": "You are using Android"
}
}
],
"iOS": [
{
"type": "showMessage",
"params": {
"text": "You are using iOS"
}
}
],
"_default": [
{
"type": "showMessage",
"params": {
"text": "You are neither using Android nor iOS"
}
}
]
}
}
}

The actions to be executed are specified in the actions parameter, in this case a switch action.

Result:

A switch action has been created