This block enables an application to take a different path when certain conditions are met.
You can use a Segmentation block to take a different path depending on the specific values of application variables. A valid ECMAScript expression containing application variables, ECMAScript operators, and Designer functions can be used to define a Segmentation Option. If this condition is evaluated to a true (Boolean) value while the application executes, the application flow takes the path of that Segmentation Option.
You can define multiple Segmentation Options, each with their own conditions. For example, the condition can be a variable with a Boolean value, a call to a function that returns a Boolean, or a combination of variables with logic operators that evaluates to a Boolean.
The first condition that evaluates successfully is selected as the segmentation path, and any blocks under that Segmentation Option are executed. If no condition expression evaluates successfully, none of the Segmentation Options execute, and the application executes the block that follows the Segmentation block.
Application variable values can be set based on logic in the application, by querying external data sources from blocks (such as the HTTP REST block), or by collecting input from a caller in the User Input block.
Conditions are ordered and exclusive, which means:
- Condition expressions are evaluated in the order they are defined.
- If one condition evaluates to true and the corresponding path is selected, then the following condition expressions are not tested. After executing this segment path, the application executes the block that follows the Segmentation block.
The Segmentation block selects the first segment whose condition is a valid ECMAScript expression that evaluates to true (Boolean). If none of the conditions evaluate to true, no segment is executed, and processing moves on to the next sibling of the Segmentation block.
The following are valid expressions:
- Using a variable whose value is true or false and comparing it to a Boolean value, such as the variable used to hold the result of a Special Days block:
isSpecialDayVar == true
isSpecialDayVar == false
- Using a Boolean property of an object stored in a variable, such as the Route Call block outcome variable:
routeCallOutcomeVar.success == true
- An expression using Boolean variables and logical operators:
var1 == false || (var2 == true && var3 == true))
- An expression using comparison operators:
var1.length > 3 || var2 === 'stop'
Click Add Condition. The Condition Expression field is pre-populated with a sample expression that you can edit by typing a condition to evaluate.
You can edit the Segment Label field to give a meaningful label to your segment. The child segment block will be named accordingly.
To remove a condition, click the trash icon for that condition in the Segmentation block or click the trash icon on the related child block.
Add a Milestone to mark this key moment while the application is running, similar to within the Milestone Block.