A condition type value is a series of criteria of which the resulting value could be either true or false. You would use a condition with the following elements:
The condition determines if the enclosed part of the if-element will be interpreted and printed;
The condition determines the choice between 2 possible values for a variable;
- cx:fetch en cx:foreach
The condition determines the selection of items actually used; the condition works as a filter.
An example of a simple condition:
activity.toEmployee.lastName = 'Jansen'
The meaning of the previous condition is: the value of the key
lastName equals "Jansen".
This proposition could be true or false.
Every simple condition consists of 3 parts:
On the left and on the right of an operator you would place values. These values are either:
- a constant value,
- the special value nil or
- a variable (be careful not to use the dollar sign $ when referencing a variable in a condition)
The following table shows the available operators you could use in conditions:
By using the logical operators AND, OR and NOT you create extended conditions by combining simple conditions. To create an extended condition enclose the simple conditions with round brackets ().
An example of a extended condition:
(x > 0) and not (x = 2)
The meaning of this extended condition is: the value of x is greater than 0 and not equal to 2.
- Always reference variables in conditions without the dollar sign $ !
- Enclose a constant string value always with double quotes, but a numeric value always without them.
- When brackets do not determine this, the logical operators are evaluated in the following order: NOT, AND and OR.