Condition expressions define a logical condition for performing a specific operation.
Update expressions can be used to add and initialize item attributes, update the values of existing attributes or elements in an array attribute, or remove (delete) attributes.
This reference outlines the supported expressions and their syntax.
The EXPRESSION notation represents a basic expression syntax, which can also be included in other expressions. An expression is typically defined as a string that can include a combination of any of the following components (depending on the context).
ATTRIBUTE, as placeholder identifiers for the related components.
- Literals (
- Attribute Variables (
- Functions (FUNCTION)
- Operators and operands (
- Other expressions (
- The names of the expression functions and operands are case insensitive.
color in (red, blue)
both work (see the
color IN (red, blue)
- String values within the expression are enclosed within single quotes (
- Expression keywords, including the names of expression operators, are reserved names in the platform. For more information, see Reserved Names.
- See the Software Specifications and Restrictions for known expression restrictions.
LITERAL represents a constant literal value. For example: 'blue'; 5; true.
ATTRIBUTE in expressions represents an attribute variable, which is the name of an item attribute — for example, first-name or color.
If an attribute name is a reserved word, such as a function name, enclose the word within acute-accent characters (
"`exists` == true"
Array-Attribute Expression Variables
Array attributes are defined in SET update expressions — for example, in the
The elements of an array attribute can be referenced in expressions using the array operator (
In most cases, Boolean values can also be used as numeric operands: the platform implicitly converts
true to 1 and
false to 0.
For example, the following update expression is valid, implicitly converting the results of the embedded Boolean expressions to 1 or 0:
res=(1 in (1,2,3,4,5))*10 + (starts('abc','xx'))*100 + (ends('abc','bc'))*1000 + (contains('abxxc','xx'))*100000;.
However, this doesn't apply to attribute comparisons because the platform verifies that the compared value matches the current attribute data type. For example, if the value of attribute
false (Boolean), the expressions
b==0 will both fail because of a type mismatch.
But an expression such as
"c = (a==5)*4 + b;" will succeed — implicitly converting the result of the
a==5 comparison from
true to 1 and the value of
false) to 0 and setting the value of attribute