When
Used with the Case (case
) command to define the conditions of a set of rules.
Command availability: IBM RPA SaaS and IBM RPA on premises
Dependencies
You can only use it with the Case (case
) and Then (then
) commands.
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
when --left(Variant) --operator(ConditionalOperators) --right(Variant) [--negate(Boolean)]
Input parameters
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Left operand | left |
Required |
Any |
Value used to evaluate the condition. |
Operator | operator |
Required |
ConditionalOperators |
Rule used to evaluate the condition. For more information, see operator parameter options. |
Right operand | right |
Required when Operator is Equal_To, Greater_Than, Greater_Than_Equal_To, Less_Than, Less_Than_Equal_To, Contains, Ends_With, Begins_With, Matches |
Any |
Value that is compared to the Left operand to evaluate the condition. |
Negate | negate |
Optional |
Boolean |
Negates the rule defined in Operator. |
operator
parameter options
The following values are supported for the Operator expression that evaluates the condition.
- Begins with
- Contains
- Ends with
- Equal to
- Greater than
- Greater than or equal to
- Is empty
- Is null
- Is null or empty
- Is true
- Less than
- Less than or equal to
- Matches
Example
The command Case is used to evaluate two conditions. The command When defines, in the first condition, if the value in Left operand is less than 3, and in the second condition, if Left operand is equal to 5. If at least one of the conditions is true, the value of the variable leftOperand is displayed using the Log Message command.
defVar --name leftOperand --type Numeric --value 5
case --name case --switches "AtLeast" --minimum 1
when --left "${leftOperand}" --operator "Less_Than" --right 3
when --left "${leftOperand}" --operator "Equal_To" --right 5
then
logMessage --message "${leftOperand}" --type "Info"
endCase
logMessage --message "End of execution" --type "Info"