if
The if
command forms a basic conditional section. This command's child commands are evaluated only if the expression in the test
attribute evaluates to a Boolean value of true
.
Child commands
Any command can be a child of if
. There should be at least one child, as a conditional section without content serves no purpose.
Attributes
test | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | Boolean | Yes |
Defines the conditional expression. Should the resolved value be a Boolean |
Examples
To make use of if
, place the commands you wish to make conditional as its children. Make sure that the EL expression for the test
attribute evaluates into a Boolean value.
<if test="${mainOpportunity.IsClosed}">
<set var="statusMessage" value="Opportunity is closed.">
<next step="endScreen">
In many programming contexts, an "if" statement is often accompanied by an "else" statement that executes when the "if" condition is not fulfilled. While there is no else
command to do this, the if-else structure can be done by using the choose command and its when and otherwise child commands.