Expression Reference


Expressions are pieces of custom functionality that can be added to a model by using an expression property. Read this reference if you would like to know what kind of expressions there are. 

Read this reference if you would like to know what kind of expressions there are. If you would like to know how to create expression properties in your data model, take a look at our tutorial article HowTo create expression properties?

Basic operators

All basic mathematical operators can be used in expressions. Take a look below! If you want to use a variable in an expression, you can use 'var:' followed by the name of the variable. In this example, we're using the variables 'a' and 'b'.

Operator Description
Mathematical operators
var:a   +   var:b var:a   plus   var:b
var:a   -   var:b var:a   minus   var:b
var:a   *   var:b var:a   times   var:b
var:a   /   var:b var:a   divided by   var:b

Conditional operators
var:a   ==   var:b var:a   equals   var:b
var:a   !=   var:b var:a   does not equal   var:b
var:a   >   var:b var:a   is greather than   var:b
var:a   <   var:b var:a   is smaller than   var:b
var:a   <=   var:b var:a   is equal to or smaller than   var:b
var:a   >=   var:b var:a   is equal to or bigger than   var:b
var:a   <   var:b  &  var:c < var:d var:a   is smaller than   var:b  and 
var:c is smaller than var:d
var:a   <   var:b | var:c < var:d var:a   is smaller than   var:b or
var:c is smaller than var:d

You can also use the words 'and' - 'or' instead of the operators '&' and '|'.

Also, you can use brackets ( ) in the same way you'd use brackets in mathematics. Please notice the difference between 2 + 2 * 2 = 6 and (2 + 2) * 2 = 8. This is the same for: var:a + var:a * var:a = 6 and (var:a + var:a) * var:a = 8.




All expressions you can use



array[number]

Returns the record corresponding to the number in an array/collection, where 0 is the first.

var:array = [ 'a', 'b', 'c' ]
var:array[1]  >>>  "b"

Note: text values need to be quoted in variables, numeric values don't
Note the differencence in [ 1, 2, 3] and ['a', 'b', 'c'] double or single quotes both suffice



avg(array)

Returns the average of a array of numbers.

var:array = [1, 2, 3]
avg(var:array) >>> 2


base64_decode("base64 text")

You can use this to decode a base64 text or a base64 file.
To assign file property, you'll need to do de decode expression in an URL expression.

(base64_encode("test") = "dGVzdA==")
base64_decode("dGVzdA==", "string") >>> "test"
base64_decode(var:base64_file_text) >>> file
base64_decode([base64 encoded file data], 'file')  >>> file

Having trouble with connecting a file? Try creating a url variable, assigning it to the file property, and then changing it to a URL expression with the base64_decode() expression.



base64_encode(text/file)

Base64_encode() lets you encode a file or text in base64 format. Base64 encoding is used in several web services, but is also a good way to transfer files.

base64_encode("test") >>> "dGVzdA=="
base64_encode(var:file)


beginning_of_month(date)

Returns the date of the first of the month from the given date.

beginning_of_month(10-03-12 13:41) >>> 01-03-12 0:00


blank?(record)

Checks if a record or variable exists. Returns false is the record or variable exists.

blank?(var:record.name) >>> true
blank?(var:record) >>> true

Blank?(var:record) is the direct opposite of present?(var:record)

When a variable had a value but has been emptied, blank?() will return false, where nil?() will return true because nil?() checks is a record or variable has a value, where blank?() checks if it exists



business_days_offset(first_date, number_of_days)

Returns a date which is the first date + the given business days (/weekdays).

business_days_offset(2014-09-13,6)  >>> 2014-09-22


capitalize(string)

Changes the first letter of a string to a capital.

capitalize("betty blocks") >>> Betty blocks


ceil(number)

Returns the next highest integer value by rounding up value if necessary.

ceil(9.2) >>> 10
ceil(9.6) >>> 10


concat(array, string)

Combines the values of an array. The second parameter defines the addition between the values.

concat(["Betty","Blocks"], " / ") >>> Betty / Blocks


count(array)

Returns the number of items in a array and hash, or returns the number of characters in a string

Array:
var:a = ["a", "b", "c", "d"]
count(var:a) >>> 4
count([1,2,3]) >>> 3

Hash:
var:b = {a: 1, b: 2, c: 3}
count(var:b) >>> 3

String:
var:c = "this is text"
count(var:c) >>> 12




day(date/datetime)

Returns the day from a specific date as a number expression.

day(2012-05-01) >>> 01
day(2017-05-20) >>> 20



days(amount)

Give an amount of days for usage in a calculation.

var:date = 2017-01-01
var:date + days(2) >>> 2017-01-03


days_offset(first_date, number_of_days)

Returns a date which is the first date + the given days.

days_offset(2014-09-13,6) >>> 2014-09-19



downcase(string)

Changes all the letters of a string to lowercase

downcase("BETTY") >>> betty


end_of_month(date)

Returns a new date representing the end of the month.

end_of_month(10-03-12 13:41) >>> 31-03-12 23:59


exclamation

! is the logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false.

!(true) >>> false


fetch(var:my_hash, my_key, my_default)

fetch(var:my_hash, my_key, my_default) returns the value for a given hash and key, with an optional default in case the key does not exist for the hash.

var:answers = 
{       "1": "answer to question 1",       "2": "answer to question 2" }
fetch(var:answers, "2", "Does not exist") >>> answer to question 2
fetch(var:answers, "3", "Does not exist") >>> Does not exist


floor(number)

Returns the largest integer less than or equal to float.

floor(9.2) >>> 9
floor(9.6) >>> 9



generate_uuid()

This expression generates an unique identifier following the UUID format. An example of when to use a UUID is when calling an external API via HTTP Request events, where the receiving API expects each request to have a unique identifier.

generate_uuid() --> f384e3ad-e6dd-4cc2-b6c9-4ad5ac5b9191



hmac_sha256(text)

Creates a hmac_sha256 hash of text and requires two arguments: the string for which you want to calculate the digest and a secret key that must be included in the calculation. It is mainly used for authentication with external API connections. You can use it to create an encrypted password.

hmac_sha256('Betty Blocks', 'key') >> 883a1fcbffa8dca9e3357a1db7ccaa337a3e8179d3113208a52c3512ee0dcb4c


hours(amount)

Give an amount of hours for usage in a calculation.

now + hours(3)


ifelse

A boolean expression replacement for IF ELSE.

record.price < 50.00 ? record.price + 5.00 : record.price >>> <br>  If record.price is below 50 then record.price + 5.00 Else record.price


ifnil(record, new_value)

A Conditional statement constructor. ifnil evaluates its argument and branches and check if no nil value applies.

ifnil(var:record.number, 0) >>> if the field is nil the field will hold the value 0,
if the field already holds a value it will keep that value


ifundefined(record, “Value”)

Check if the image or file property contains a file, the return can be written to a variable.

var:image_present = "", ifundefined(var:image_2, "false") >>  var:image_present = "false"


include?([array], object)

Returns true if the given object is present in self

"include?(['a', 'b', 'c'], 'b')" >>> true


int(value)

Converts a text to an integer.

var:text = "10"
10 + int(var:text) >>> 20


keys(var:my_hash)

keys(var:my_hash) returns a collection of all keys in the hash. 

var:answers = 
{       "1": "answer to question 1",       "2": "answer to question 2" }
keys(var:answers) >>> ["1", "2"]


liquid()

liquid() enables you to use liquid inside an expression.

liquid({{record.id}})



ljust(string_number_of_characters)

Adds a specific number of whitespaces right of a string.

ljust("betty", 3) >>> [start]betty   [end]


max(array)

Returns the highest number of a array of numbers.

max([1,2,3]) >>> 3



md5(text)

Creates a md5 hash of text and is mainly used for authentication with external API connections. You can use it to create an encrypted password.

md5('Betty Blocks') >> f6e8a2baa494d57bd9c8b053f1fba164


min(array)

Returns the lowest number of a array of numbers.

min([1,2,3] >>> 1)


minutes(amount)

Give an amount of minutes for usage in a calculation.

now + minutes(30)


modulo(value, divider)

Returns the modulo of a number.

modulo(21, 5) == 1



monday_of_week_number(year, weeknumber)

Returns the date of the monday of the given week and year

monday_of_week_number(2017, 1) >>> 02-01-2017



month(date/datetime)

Returns the month from a specific date as a number expression.

month(2012-05-01) >>> 05


months(amount)

Give an amount of months for usage in a calculation.

today + months(3)


newline

Starts the following inputs on a new line.

"Hello" + newline + "World" >>  Hello World


nil?(record)

Checks if a fields value is empty.

nil?(var:record.email) >>> true


now

Returns the current date and time as a date time expression.

Date=01-01-15 Time=10:00:00  >> now >> 01-01-15 10:00:00


only_numbers(string)

Returns the numbers out of a string.

only_numbers("a7263s11") >>> 726311


parameterize(string)

Changes a string to a parameter.

parameterize("betty blocks") >>> betty-blocks

Note: Used to make URLs



pow(value, power)

var:a raised to the power of var:b

pow(5, 5) == 3125



present?(record)

Checks if a record or variable exists. Returns true if the record or variable exists.

present?(var:record)  >>> true

present?(var.record.name) >>> true

Present?(var:record) is exactly the same as !(blank?(var:record))



random (number)

Returns a random number between 0 and the given argument.

random(8) >>> 6

random(8) >>> 3

random(8) >>> 1



random_hex(number_of_characters)

Randomly generates a hexadecimal string. The number_of_characters argument defines the number of letters the result string consists.

random_hex(6) >>> bf66d1


read_file(file_location)

Can read the content of a file.

read_file(var:record.file)

Only UTF-8 encoded files are supported.



regex_replace("input", "what_to_replace", "replace_with_what")

Replace a coded value with a different value. You'll need this one to perform a replace on anything with a backslash.

regex_replace("Betty \n Blocks", "\n", "from the") >> Betty from the Blocks

\n is the value which represents a newline/enter, such as the <br>-tag in html.



replace(record, what_to_replace, replace_with)

Replace a set of letter with a different set.

replace("Berry Blocks", "rry", "tty") >> Betty Blocks


rjust(string, number_of_characters)

Adds a specific number of whitespaces left of a string.

rjust("betty", 3) >>> [start]   betty[end]


round(float, amount_of_digits_after_the_decimal)

Rounds a float to a given precison in digits. Defaults 0 digits.

round(99.8) >>> 100

round(99.876, 2) >>> 99.88



rsa_encrypt(var:somejson, var:pemfile)

Encrypt JSON with a .pem file

rsa_encrypt(var:somejson, var:pemfile) >>> encrypted code



seconds(amount)

Give an amount of seconds for usage in a calculation.

now + seconds(120)


sha1(text)

Creates a sha1 hash of text and is mainly used for authentication with external API connections. You can use it to create an encrypted password.

sha1("betty blocks") >> 65afa77d0b5122a10eafe73a2d0f42c33041086b


sha256(text)

Creates a sha256 hash of text and is mainly used for authentication with external API connections. You can use it to create an encrypted password.

sha256("betty blocks") >> 3e03887797ab5e9d18da9ac8e64abc3dfb30a6647e51ac1a71ae47033ffa9872


sha512(text)

Creates a sha512 hash of text and is mainly used for authentication with external API connections. You can use it to create an encrypted password.

sha512("betty blocks") >> 569DAD2594EF64B6B37A3E86040321A189E83E78F68A9883E984213F41AF3B2C98174CDE35D5974901531580FDFDF1030F69932DEECEDE8D79CD5D584E7F7BBF



slice(array, start, lenght)

Slices an array on the given value.

var:array = [ 'a', 'b', 'c', 'd', 'e', 'f' ]

slice(var:array, 2, 3) >>> [ 'c', 'd', 'e' ]



split(string, split_string)

Splits a string based on a argument, returns a array.

split("Betty Blocks", " ") >>> ["Betty","Blocks"]


squeeze(string)

Removes double characters from a string, like whitespaces.

squeeze("moon  gees") >>> mon ges


str(value)

 Converts a value to a string.

str(10) + str(10) >>> 1010


strftime(datetime, format)

Creates a string based on a format applied to a datetime. Use this as a date expression.

strftime(2012-05-01T07:23:34, "%d/%m/%Y")  >>> 01/05/2012

Click here for all date formats.



string operators

Some basic operators also work on strings. You can use a plus (+) to concatenate two strings and a asterisk/times (*) to repeat a string a number of times.

"Betty" * 3 >>> "BettyBettyBetty"

"Betty" + "Blocks" >>> "BettyBlocks"



strip(string)

Removes all trailing whitespaces of a string.

strip(" betty ") >>> betty


substring(inputstring, startposition, endposition)

Retrieves characters from a selection of a string.

substring("BettyBlocks", 6, 10) >>> Block


sum(array)

Returns the sum of all the numbers in an array

sum([1,2,3]) >> 6


to_json(text)

Transforms text to JSON format

to_json('{[\"key\":\"123\"]}') >>> {["key" : "123"]}



today

Returns the current date as a date expression. If a date time is used, the time will be set to 00:00:00.

Date=01-01-15   >> today >> 01-01-15


truncate(string, number_of_characters, text_after_trun)

Shortens a string based on the maximum number of characters. Standard “…” is added behind the return, you can change this by sending a 3rd parameter.

truncate("Betty Blocks", 5) >>> Betty…

truncate("Betty Blocks", 5, "%") >>> Betty%



uniq(array)

Removes all double values in an array. This also works with an array of string-values.

uniq([1,2,2,3]) >>> [1,2,3]


upcase(string)

Changes all the letters of a string to capitals.

upcase("betty") >>> BETTY


values(var:my_hash)

values(var:my_hash) returns a collection of all values in a hash.

var:answers = 
{       "1": "answer to question 1",       "2": "answer to question 2" }
values(var:answers) >>> ["answer to question 1", "answer to question 2"]


weeks(amount)

Give an amount of weeks for usage in a calculation.

today + weeks(2)


xpath(var:xml, "/path")

Returns the given element of a XML text property. If you only want the value, append /text() to your path.

Add true to the expression to ignore any other attributes (like xmlns="value").

var:xml = <document xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"> <note> <to>Adam</to> <from>Eve</from> <heading>Cheers!</heading>< <body>Wow! What a platform! </body> </note> </document>

xpath(var:xml, "/document/note/body", true) >>> <body>Wow! What a platform! </body>
xpath(var:xml, "/document/note/body/text()", true) >>> Wow! What a platform!

Tip: You can use tools like this xpath generator if you don't want to search for the precise path you need yourself.



year(date/datetime)

Returns the year from a specific date as a number expression.

year(2012-05-01) >>> 2012


years(amount)

Give an amount of years for usage in a calculation.

today + years(2)

Didn’t find what you want?Ask your question on the forum!