IF/THEN Logic expressions and syntax
Write IF/THEN Logic expressions using the Navixy JEXL-based expression language. Expressions route data by evaluating to true or false, though a missing value can behave differently.
Expression fundamentals
The IF/THEN Logic node uses the Navixy IoT Logic Expression Language, based on Java Expression Language (JEXL). Expressions are meant to return true or false, but a missing value doesn't always follow that rule. Some operators route a missing value to THEN instead of ELSE, and some leave the stored attribute null rather than false. See Missing values and null routing before relying on a comparison to fail safely.
Expression evaluation: Expressions are evaluated from left to right, and you can use parentheses to control the order of operations.
Basic syntax example:
condition1 && (condition2 || condition3 > condition4)Available operators
Comparison operators
==
Checks if two operands are equal. If operands are of different types, JEXL converts them to one if possible
!=
Checks for inequality of two operands. Returns true if operands are not equal
<
Checks that the left operand is smaller than the right operand
<=
Checks that the left operand is smaller or equal to the right operand
>
Checks that the left operand is larger than the right operand
>=
Checks that the left operand is larger or equal to the right operand
For how missing values affect routing, see Missing values and null routing.
Logical operators
&& or and
Logical AND - checks if two conditions are true. Returns true if both conditions are true
|| or or
Logical OR - checking for the truth of at least one of the two conditions
! or not
Logical NOT - converts the result of the condition to the opposite value
Pattern matching operators
=~
Checks if the value of the left operand is in the set of the right operand. For strings, checks for regex pattern match
!~
Checks if the value of the left operand is not in the set of the right operand. For strings, checks for regex pattern mismatch
=^
Checks that the left string operand starts with the right string operand
!^
Checks that the left string operand doesn't start with the right string operand
=$
Checks that the left string operand ends with the right string operand
!$
Checks that the left string operand doesn't end with the right string operand
Geofence functions
Three functions evaluate a device's position relative to a named Navixy geofence, and a fourth one returns the name of the geofence the device is in. For usage instructions and examples, see Geofence functions.
inGeofence(id)
Geofence ID
The device is currently inside the geofence
enterGeofence(id)
Geofence ID
The device has just crossed into the geofence
leaveGeofence(id)
Geofence ID
The device has just crossed out of the geofence
Current position:
The geofence name appears as a comment for readability and has no effect on evaluation. The geofence picker inserts this format automatically.
Historical position:
The second parameter is the index of the data packet (0 for the current one, 1 for the previous one, up to 11), and the third is the validity filter, following the same convention as value(). Both are optional, and both apply to inGeofence() only. enterGeofence() and leaveGeofence() take the geofence ID and nothing else. Don't wrap a geofence function inside value(): the first parameter of value() is an attribute name, not an expression.
Expression examples
Missing values and null routing
Common symptom: A condition fires on a device's very first packets, before the referenced attribute has ever arrived. This usually means the condition uses != (or a negated pattern operator) against a missing value. See Comparison operators with null operands and Logical operators with null operands for which operators are safe by default and which need a guard.
A referenced attribute resolves to null in four cases:
It has never been sent for this device.
It's absent from the current packet, but an earlier packet still holds a value.
The requested history index doesn't exist yet.
The device sent nothing for more than 30 days, so Navixy dropped its stored history.
JEXL treats all four the same way, as null, so an operator's behavior on a missing value doesn't depend on which of the four caused it. A never-sent attribute doesn't error the flow. For the 30-day retention of stored values, see Full syntax.
For why a missing value stops an expression, and for the comparison patterns that prevent it in both node types, see Missing values in expressions.
Every incoming message leaves the Logic node through exactly one branch, THEN or ELSE, even when the condition references missing data. If the condition's overall result is anything other than true (including null, or a value the node can't evaluate), the message routes to ELSE. The ELSE path therefore carries both "condition is false" and "condition could not be satisfied from available data."
Null-safe condition patterns
Presence guard (recommended when a condition must apply only to packets that carry the attribute). The stored attribute is a real true/false here, not null:
Explicit missing-data check: null literals are accepted in conditions.
|| chain ordering: Put the term that may be null last. Ordering helps only on packets where the left operand is true, so treat it as an improvement rather than a fix.
Unsafe: the null left operand routes to ELSE even though speed > 50 is true on the same packet.
Better: a true left operand short-circuits before the null right operand is evaluated. On a packet where the speed is 20, the null right operand is still evaluated, and the condition still routes to ELSE.
For a form that works on every packet, compare each term explicitly. See Compare a value explicitly.
Don't rely on !() to detect missing data: When x is null, both x > 5 and !(x > 5) route to ELSE.
'all' vs 'valid': value(attr, 0, 'valid') can return the last non-null reading from an earlier packet. The condition may still evaluate against a real value even when the current packet is missing it. Use 'all' when the condition must reflect the current packet only.
Comparison operators with null operands
<, <=, >, or >= against a missing value
ELSE
null
!= against a missing value and a non-null literal (e.g., value('a', 0, 'all') != 1)
THEN
true
== against a missing value and a non-null literal
ELSE
false
== null against a missing value
THEN
true
!= null when the attribute is absent
ELSE
false
!= null when the attribute is present
THEN
true
=~ against a missing value and a string literal or a list
ELSE
false
!~ against a missing value and a string literal or a list
THEN
true
=^ or =$ against a missing value() result
ELSE
false
!^ or !$ against a missing value() result
THEN
true
=^, !^, =$, or !$ against a missing attribute referenced by name
ELSE
null
Logical operators with null operands
!(x > 5) when x is missing
ELSE
null
Null operand in `
` evaluated before a true operand on the same packet
True operand in `
` evaluated before a null operand (short-circuits)
Null operand in && with a true operand, either order
ELSE
null
false operand in && evaluated before a null operand (short-circuits)
ELSE
false
false operand in `
` evaluated before a null operand
Order matters for both operators. Each one evaluates the left operand first and stops there when the left operand already settles the result. A false left operand settles &&, and a true left operand settles ||. In every other combination the null operand is evaluated, the condition resolves to null, and the message routes to ELSE.
A true operand can't short-circuit past a null one in &&, since AND still needs to know whether the null side would fail the condition. A false operand can, and the node then stores a real false rather than null. For the same rule applied to attribute formulas, and for the comparison patterns that avoid it, see Missing values in expressions.
Error handling scenarios
Expression evaluates to true
Success
THEN connection
true
Expression evaluates to false
Success
ELSE connection
false
Referenced attribute is null and used alone, with no comparison operator
Resolves to null
ELSE connection
null
Missing value compared with <, <=, >, or >=
Resolves to null
ELSE connection
null
Missing value compared with == and a non-null literal
Evaluates to false
ELSE connection
false
Missing value compared with == null
Evaluates to true
THEN connection
true
Missing value compared with != and a non-null literal
Evaluates to true
THEN connection
true
Syntax error in expression
Resolves to null
ELSE connection
null
Practical implementation examples
Last updated
Was this helpful?