The following is a list of available functions
Field Name | Function | Example |
---|---|---|
fn.datetostr(date, pattern) | Converts a date into a string value. |
fn.datetostr(contact.values.BIRTHDATE, 'dd/MM/yyyy') |
fn.datetostr_tz(date, pattern, timezone) | Converts a date into a string value. This function is applied using a specific timezone. |
fn.datetostr_tz(contact.values.BIRTHDATE, 'dd/MM/yyyy', 'Europe/Rome') |
fn.strtodate(string, pattern) | Converts a string value into a date. |
fn.strtodate(contact.values.MYFIELD, 'dd/MM/yyyy HH:mm') |
fn.strtodate_tz(string, pattern, timezone) | Converts a string into a date value. This function is applied using a specific timezone. |
fn.strtodate_tz(contact.values.MYFIELD, 'dd/MM/yyyy HH:mm', 'Europe/Rome') |
fn.now() | Returns the current date and time. | |
fn.today() | Returns today's date and the time set to 00:00:00. | |
fn.today_tz(timezone) | Returns today's date and the time set to 00:00:00 relative to the set timezone. | |
fn.midnight(date) | Returns the original date and the time set to 00:00:00. | |
fn.midnight_tz(date, timezone) | Returns the original date and the time set to 00:00:00 relative to the set timezone. | |
fn.dateadd(date, offset, unit) | Adds an amount of time to a date in a specific time unit (year, month, day, hour, minute, second, dayofweek). | fn.dateadd(contact.values.EXPIREDATE, -2, 'day') |
fn.dateadd_tz(date, offset, unit, timezone) | Adds an amount of time to a date in a specific time unit (year, month, day, hour, minute, second, dayofweek). This function is applied using a specific timezone. |
fn.dateadd_tz(contact.values.EXPIREDATE, -2, 'day', 'Europe/Rome') |
fn.datediff(date1,date2, unit) | Returns an int value representing the difference between two dates in a specific time unit (year, month, day, hour, minute, second, dayofweek). | fn.datediff(fn.now(), contact.values.EXPIREDATE, 'day') |
fn.datepart(date1, unit) | Returns a string value representing the part of a date that corresponds to the indicated time unit (year, month, day, hour, minute, second, dayofweek). |
fn.datepart(contact.values.EXPIREDATE, 'month') |
fn.datepart_tz(date1, unit, timezone) | Returns a string value representing the part of a date that corresponds to the indicated time unit (year, month, day, hour, minute, second, dayofweek).This function is applied using a specific timezone. |
fn.datepart_tz(contact.values.EXPIREDATE, 'month', 'Europe/Rome') |
fn.age(date) | Returns an int representing the age based on a date, in years. |
fn.age(contact.values.BIRTHDATE) |
fn.age_tz(date, timezone) | Returns an int representing the age based on a date, in years. This function is applied using a specific timezone. |
fn.age(contact.values.BIRTHDATE) |
fn.round(var) | Returns a rounded numeric value. | |
fn.max(a,b) | Returns the highest value between two numeric values or two dates. | |
fn.min(a,b) | Returns the lowest value between two numbers or two dates. | |
fn.abs(var) | Returns the absolute value of a numeric value. | |
fn.md5(var) | Returns a string representing the value calculated with the MD5 algorithm and printed in base 16. | |
fn.sha1(var) | Returns a string representing the value calculated with the SHA-1 algorithm and printed in base 16. | |
fn.sha256(var) | Returns a string representing the value calculated with the SHA-256 algorithm and printed in base 16. | |
fn.random(min,max) | Returns an integer between the defined minimum and maximum values, inclusive. | |
fn.strtolist(string, separator) | Converts a string into a list, using the specified separator. | fn.strtolist('Italy,France,UK', ',') |
fn.listtostr(list, separator) | Converts a list into a string, using the specified separator. | fn.listtostr(contact.values.COUNTRY, ',') |
fn.randomelement(list) | Extracts an element from a collection or list of strings (strings should be separated by a comma). | fn.randomelement('Red,Yellow,Green') |
fn.sort(list,direction) | Sorts a list using a natural sorting function (for strings, it's alphabetical order). Use direction='asc' for ascending order and direction="desc" for descending order.Any other value or list is treated as asc . |
|
fn.sortby(list,field,direction) | Sorts a list of records using the field value of each record. Use direction='asc' for ascending order and direction="desc" for descending order. Any other value or list is treated as asc . |
|
fn.filter(list,condition) | Filters a list of records by evaluating the "condition" for each of the records. If applied to lists of primitive values such as strings or numbers, you must use the special keyword this to refer to the value. |
Example with records: fn.filter(myqueryresultset,'name eq "xx"') Example with primitive values: fn.filter(fn.strtolist('Italy,France,UK', ','),'this contains "tal"') |
fn.ucase(string) | Converts a string to UPPERCASE. If applied to a list, the function is applied to all its elements. | |
fn.lcase(string) | Converts a string to lowercase. If applied to a list, the function is applied to all its elements. | |
fn.capitalcase(string) | Converts the first letter of each word to uppercase and the others to lowercase. If applied to a list, the function is applied to all its elements. | |
fn.trim(string) | Removes all unnecessary spaces from a string. | |
fn.left(string, maxchars) | Returns the left part of a string or list equal to the specified number of characters/elements. | |
fn.right(string, maxchars) | Returns the right part of a string or list equal to the specified number of characters/elements. | |
fn.mid(string, from, to) | Extracts a portion of string or list (from=0 is the first element, to is always mandatory). |
|
fn.len(var) | Returns the length of a string or a list. | |
fn.concat(var1, var2) | Concatenates the string representation of two variables. null values are treated as empty strings. For date/timestamp values, it's better to format them using fn.strtodate_tz . |
|
fn.ifempty(string, defaultvalue) | If the string is "" or empty, it returns the specified value; otherwise, it returns the original value. | |
fn.coalesce(var, defaultvalue) | If var is empty, it returns the specified value; otherwise, it returns the original value. | fn.coalesce(contact.values.ORDERS, 0) |
fn.extract(list, fieldname) | Extracts the field defined in fieldname from each element of the list and returns a list of the extracted fields (in the same order as the input list). |
fn.extract(listofperson, 'name') |
fn.compose(list, fieldname) | Assembles a list of records (field-value pairs), each element will have a field named fieldname containing the corresponding value from the original list (in the same order as the input list). |
|
fn.base64_encode(string) | Encodes a utf-8 string using the base64 encoding scheme. |
|
fn.base64_decode(string) | Decodes a utf-8 string encoded in base64 . |
|
fn.url_encode(string) | Encodes a string into the URL query string parameter representation using utf-8 encoding (java URLEncoder.encode). |
|
fn.url_decode(string) | Decodes a string from URL query string parameter representation using utf-8 encoding (java URLDecoder.decode). |
|
fn.url_appendparameter(url,name,value) | Treats a URL as an URL, and adds to the query string a parameter named name with the value value after the "?" symbol and before the "#" symbol.The value MUST be already encoded, using the url_encode function. |
|
fn.replace(string, occurrence, replacement) | Replaces all occurrences in the given string. | |
fn.strtonumber(numer_as_string, decimal_separator) | Converts the string to a number. If decimal_separator is not null, it is considered for the conversion. |
|
fn.first(list) | Returns the first element of the given list/collection. | |
fn.last(list) | Returns the last element of the given list/collection. | |
fn.elementAt(list, index) | Returns the element in the list at position index (the first element has index 0). | |
fn.json_encode(obj) | Converts the passed object into a JSON string. | |
fn.json_decode(string) | Converts the passed JSON string into the corresponding object. | |
fn.preg_replace(regex_pattern, replacement, string) | Applies a substitution via regex on the string with replacement. | |
fn.anniversary(birthday) | Returns the anniversary date (if it has already passed, the date of the next anniversary). | |
fn.anniversary_tz(birthday, timezone) | Returns the anniversary date (if it has already passed, the date of the next anniversary). The function is applied considering the passed timezone. |
Note: The date management functions use the timezone of the contacts for whom the code is being executed.
Examples
Boolean expression:
contact.values.lingua EQ 'ITA'
(contact.values.field1 EQ 4 OR contact.values.field1 EQ 5+1) AND contact.values.field2 NEQ NULL
contact.subscribed and contact.values.DOMINIO EQ 'gmail.com'
String expression:
'Value1'
contact.values.NAME & '-' & contact.values.SURNAME
Numeric expression:
(contact.values.A + contact.values.B)/2