Logic notation is the way in which logical concepts and their interpretations are expressed in natural languages. Tracardi uses logic notation in segment configuration, IF plugin action,or other conditional statements.
The following grammar define logic expression syntax.
that means that expressions with similar operators e.g. OR must be in brackets.
The following conditional statement is forbidden:
correct statement is either:
There is no auto resolution of priority operations
Each condition consist of a field, operator, and value. An operator is used to manipulate individual data items and return a result. Operators are represented by special characters or by keywords. List of operators is available below.
This example will return true if numberOfPurchases in payload equals 1. Fields are in a dot notation.
Operations can be joined by AND/OR.
This example will return True if numberOfPurchases in payload equals 1 and title in payload equals "Title".
If there is a data missing. For example:
then you will see an error: Missing Value. To prevent it you will need to check if the data exists or is not empty. To do so type:
This way when data does not exist or is empty then the rest of the condition will not be checked and the result will be
FALSE. Otherwise, when the
firstname.lastname@example.org exists and is equal 1 then the result is TRUE.
The order in the condition does mather.
Type of operators
There are other operators possible like:
- less then (<)
- greater then (>)
- less or equal then (<=)
- greater or equal then (>=)
- not equal (!=)
- exists (field_name EXISTS)
- not exists (field_name NOT EXISTS)
- empty (field_name EMPTY)
- not empty (field_name NOT EMPTY)
- consists (field_name CONSIST "text" )
- starts with (field_name STARTS WITH "text" )
- ends with (field_name ENDS WITH "text" )
Example of operator use
In the example:
Field payload@numberOfPurchases is considered an integer number while payload@title is considered a string.
Values of differnet types can not be compared.
Functions can be used to convert value, for example to certain types.
- now() - returns current date and time
- utcnow() - returns current UTC date and time
- datetime(field_name) - returns field_name field content as date and time
- now(time_zone) - returns current date and time with given timezone info
- now.offset(offset) - returns current date and time with given offset (e.g. -15m)
- now.timezone.offset(timezone, offset) - returns current date and time with given timezone info with applied offset
- datetime.offset(field_name, offset) - returns field_name field content as date and time with applied offset
- datetime.timezone(field_name, timezone) - returns field_name field content as date and time with timezone info
- now.timezone(timezone) - returns current date and time with given timezone info
- lowercase(field_name) - returns lowercased text value of field_name
- uppercase(field_name) - returns upper-cased text value of field_name
- datetime.from_timestamp(field_name) - returns date and time created from timestamp content of field field_name