ifElse
Syntax
ifElse($test, $then, $else)
$test.ifElse($then, $else)
Description
Returns the result of the evaluation of then or else depending on the evaluation of test. If the evaluation of test is true, then then is evaluated and the result is returned, otherwise else.
Alternative notation for if($text, $then, $else), which sometimes fits more legibly into an evaluation chain, see if .
For case distinctions where multiple conditions must be evaluated, there is the alternative switch syntax. This avoids the nesting of conditions and leads to a much better readability in this case.
Parameters
| Name | Type | Description | Mandatory | Default |
|---|---|---|---|---|
| test | Business object | An expression that returns true or false after evaluation. |
yes | |
| then | Business object | An expression that evaluates when test returns true . |
yes | |
| else | Business object | An expression that evaluates if test results in false. |
yes |
Return value
Type: Business object
The result of evaluating then or else, depending on the result of test.
Examples
{
x = 55;
($x % 10 == 0).ifElse($x / 10, $x * 2)
}
Output: 110
If x is divisible by 10, the result of x/10 is returned. Otherwise the result of x*2