Relational Operators
Operator | Purpose |
---|---|
== | Equal |
!= | Not equal |
< | Less than |
<= | Less than or equal |
> | Greater than |
>= | Greater than or equal |
These are used to compare two values. Note that equality is checked via ==, not =.
As we learned, = is an assignment operator, which assigns a value to a variable. It does not check if the value of the variable is the same as another value.
Example
def a = 1 (variable a now holds value 1)
def b = 1 (variable b now holds value 1)
To check if variable a is equal to variable b:
a == b
Logical Operators
Operator | Purpose |
---|---|
&& | AND |
|| | OR |
! | NOT |
These are the most important logical operators in the context of Sales Cloud. For a complete list of all the Logical Operators, please check this link.
However, it is doubtful you will use any other logical operators while scripting in Application Composer.
&& (AND)
When we use this operator, we want all the conditions to be met at the same time before an action is done.
For example:
def a = 1
def b = 2
def c = 1
a == c && a < b (both conditions have to be met at the same time before code continues to execute)
|| (OR)
When we use this operator, we want at least one of the conditions to be met before we continue.
For example:
def a = 1
def b = 2
def c = 1
a == c || a == b (if one of the two conditions is true, the code continues to execute. In this case, a == c is true, so our code will continue execution)
! (NOT)
This operator gives the reverse of a Boolean value.
So if we say !true, that means false. If we do !false, that means true.