Warning!
This is a legacy document. The features described below are only usable within the classic generation environment.
Classic expressions can not be directly connected to next-gen features, please consider using next-gen actions if you wish to use value calculations for your application.
Read this reference if you would like to know what kinds of expressions there are.
Use expressions in your actions to get specific and complex results you can not get from static data model properties.
Consider carefully when you use a property expression since an expression is triggered on every create and update. When there are too many expressions or the expression is triggered a lot of times, then it will hurt its performance. Furthermore, the expression’s output will not instantly be generated. If your actions rely on the expression’s output (for example in a PDF template), you might get some unexpected or blank results.
Good to know: every time an expression has to be calculated, the background jobs will be automatically paused. After finishing all the expressions, the background jobs will be continued.
Best practice To get better performance and more flexibility, use one of the properties (without expression):
Create an action with the trigger BEFORE SAVE or AFTER SAVE (dependent on which case). The action can calculate the expression and save the desired output every time a record is saved. |
Note: We advise creating expressions in your action and assigning the value to your model object instead of creating expressions within your data model to keep the calculation speed to a minimum.
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.
You can also use the words and
- or
instead of the operators &
and |
.
Also, you can use brackets ( )
in the same way you use brackets in mathematics. Note: The different results as 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`.
You can also use the words and
- or
instead of the operators &
and |
.
Also, you can use brackets ( )
in the same way you use brackets in mathematics. Note: The different results as 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`.
Below is an overview of all expressions in Betty Blocks, in alphabetical order.
any_blank? (array) |
var:collection = ["Betty", "Blocks", ""] |
Checks if there are blank values in the collection. Returns true or false. |
any_nil?(collection) |
var:collection = ["Betty", "Blocks", nil] |
Checks if there are nil values in the collection. Returns |
Note: There's a difference between nil and |
any_not_blank?(collection) |
var:collection = ["Betty", "Blocks", ""] |
Checks if there are non-blank values in the collection. Returns |
any_not_nil? (collection) |
var:collection = ["Betty", "Blocks", nil] |
Checks if there are non-nil values in the collection. Returns |
any_starts_with? (collection, value) |
var:collection = ["Betty", "Blocks", "Alkmaar"] |
Checks if there's any objects starting with the value entered in the expression. |
array[number] |
var:collection = [ "a", "b", "c" ] |
Returns the object/record corresponding to the number in an array/collection, where 0 is the first. |
Note: Text values need to be quoted when used in variables, numeric values don't. Note the difference in |
avg (array) |
var:array = [1, 2, 3] |
Returns the average of an array of numbers. |
base64_decode (value, format, extension) |
var:base64 = base64_encode("test") >>> "dGVzdA==" |
You can use this to decode a base64 text or a base64 file. |
The third parameter is considered to be a file with extension, when the name contains a When decoding with the |
base64_encode (text/file) |
base64_encode("test") >>> "dGVzdA==" |
|
beginning_of_month (date) |
beginning_of_month(10-03-12 13:41) >>> 01-03-12 |
Returns the date of the first of the month from the given date. |
blank? (record) |
var:record.name = "Robert"
|
Checks if a record or variable exists. Returns |
boolean_match (value, regex) |
var:value = "Betty Blocks!" |
Checks if a value matches a Regex. Returns |
business_days_offset (date, number_of_days) |
business_days_offset(2019-04-10,6) >>> 2019-04-18 |
Returns a date which is the date + the given business days (/weekdays). |
capitalize (string) |
capitalize("betty blocks") >>> Betty blocks |
Changes the first letter of a string to a capital. |
ceil (number) |
ceil(9.2) >>> 10 |
Returns the next highest integer value by rounding up value if necessary. |
concat (array, string) |
concat(["Betty","Blocks","Alkmaar"], " / ") >>> Betty / Blocks / Alkmaar |
Combines the values of an array. The second parameter defines the addition between the values. |
count (array) |
Array var:a = ["a", "b", "c", "d"]
Hash var:b = {a: 1, b: 2, c: 3}
String var:c = "This is text" |
Returns the number of items in an array and hash, or returns the number of characters in a string. |
count_full_collection (collection) |
All records: Robert, Marcel, Thomas, Jermel, Ralph, Chris |
Count the number of records in a collection, ignoring the set limit, without rendering the full collection. |
day (date/datetime) |
day(2019-05-01) >>> 1 |
Returns the day from a specific date as a number expression. |
days (amount) |
var:date = 2019-01-01 |
Use an amount of days in a calculation. |
days_offset (date, number) |
days_offset(2019-04-10,10) >>> 2019-04-20 |
Returns a date, which is the date + the given days. |
decode_jwt(algorithm, secret, jwt) |
var:algorithm = "HS256" |
Decodes a JSON Web Token. |
downcase(string) |
downcase("BETTY") >>> betty |
Transforms all characters of a string to lowercase. |
end_of_month(date/datetime) |
end_of_month(10-03-19) >>> 31-03-19 00:00:00 |
Returns a new date representing the end of the month. |
errors!(object) |
var:object (description is required, but blank) |
Executes validations and returns the errors (if any) as a hash, in one go. |
exclamation |
!(true) >>> false |
|
extname(file) |
var:file = avatar.png |
Returns the extension of a file. |
fetch(hash, key, default) |
var:answers = |
Returns the value for a given hash and key, with an optional default in case the key does not exist for the hash. |
float(string) |
var:text = "2.5" |
Transforms a string to a float (decimal number). Only accepts |
floor(number) |
floor(9.2) >>> 9 |
Returns the largest integer less than or equal to the given (decimal) value. |
generate_jwt(algorithm, secret, payload) |
var:algorithm = "HS256" |
Generate a JSON Web Token. |
generate_uuid() |
generate_uuid() >>> f384e3ad-e6dd-4cc2-b6c9-4ad5ac5b9191 |
Generate a 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. |
gethostbyname(domain) |
gethostbyname("bettyblocks.com") >>> 37.46.139.160 |
Returns an IP address based on the given domain. |
hash?(variable) |
var:hash = { "a" : "1" , "b" : "2" , "c" : "3" } |
Checks if a variable can be parsed as a hash. Returns |
hmac_sha256(text, secret) |
hmac_sha256("Betty Blocks", "secret") >>> ec1d3a29ae219e55fa3c3a3055a25b6ba514e0acadcb1d198798dc48dc978a66 |
Creates a |
hmac_sha384(text, secret) |
hmac_sha384("Betty Blocks", "secret") >>> 4b642d2c4b3ca8349714cfa4d8bed17570c94284e06e07889d9fe6b0c0c2cd9a37e91d684632803943535d149b582382 |
Creates a |
hmac_sha512(text, secret) |
hmac_sha512("Betty Blocks", "secret") >>> 14dd565a61c4ac3aab353edae6f81dc9225c99a90f0e138bea494c359e3ee40cbf9f581ecc57205722e8d6ed22c0748d65685e98dcd90e3264b4392d4bdbed48 |
Creates a |
hours(amount) |
2019-01-04 12:00 + hours(3) >>> 2019-01-04 15:00 |
Use an amount of hours in a calculation. |
ifelse |
record.price < 50.00 ? record.price + 5.00 : record.price >>> If record.price is below 50 then record.price + 5.00 Else record.price |
A boolean expression replacement for IF ELSE. |
ifnil(value, default) |
var:value = "Betty Blocks" |
A conditional statement constructor. |
include?(array, object) |
include?(['a', 'b', 'c'], 'b') >>> true |
Returns |
int(value) |
var:text = "10" |
Converts a text to an integer. |
keys(hash) |
var:answers = |
Returns an array of all keys in the hash. |
ljust(text, number_of_characters) |
ljust("Betty", 10) >>> "Betty " |
Adds a specific number of whitespaces right of a text value, so the width matches the number given in the expression. |
localize(date) |
var:date = 2019-03-01 |
Returns a date value in the given format, based the application's locale. |
math_sqr(number) |
var:number = 10 |
Returns the square of the variable in the brackets. |
math_sqrt(number) |
var:number = 100 |
Returns the squareroot of the variable in the brackets. |
math_sin(number) |
var:number = 1 |
Returns the sine of the variable in the brackets. |
math_cos(number) |
var:number = 1 |
Returns the cosine of the variable in the brackets. |
math_tan(number) |
var:number = 1 |
Returns the tangent of the variable in the brackets. |
math_asin(number) |
var:number = 0.8414709848078965 |
Returns the arcsine of the variable in the brackets. |
math_acos(number) |
var:number = 0.5403023058681398 |
Returns the arcosine of the variable in the brackets. |
math_atan(number) |
var:number = 1.557407724654902 |
Returns the arctangent of the variable in the brackets. |
math_atan2(number, number) |
var:number1 = 3 |
Returns the arctangent of the two variables in the brackets. |
math_log(number) |
var:number = 3 |
Returns the logarithm of the variable in the brackets. |
math_log2(number) |
var:number = 3 |
Returns the logarithm with base 2 of the variable in the brackets. |
math_log10(number) |
var:number = 3 |
Returns the logarithm with base 10 of the variable in the brackets. |
math_abs(number) |
var:number = -3.1415927 |
Returns the absolute of the variable in the brackets. |
math_deg_to_rad(number) |
var:number = 45 |
Returns the radian number of the variable in the brackets. |
math_rad_to_deg(number) |
var:number = 0.7853981633974483 |
Returns the degrees of the variable in the brackets. |
math_pi() |
math_pi() >>> 3.141592653589793 |
Returns pi. |
math_exp(number) |
var:number = 3 |
Returns the output of Euler by the power of given value |
math_e() |
math_e() >>> 2.718281828459045 |
Returns Euler. |
max(array) |
max([1,2,3]) >>> 3 |
Returns the highest number of an array of numbers. |
md5(text) |
md5("Betty Blocks") >> f6e8a2baa494d57bd9c8b053f1fba164 |
Creates an Note: We do not recommend using this expression for encryption of sensitive data. It can still be used for other, none-cryptographic purposes, though. See MD5 for more information.
|
min(array) |
min([1,2,3]) >>> 1 |
Returns the lowest number of an array of numbers. |
minutes(amount) |
2019-01-04 12:00 + minutes(30) >>> 2019-01-04 12:30 |
Use an amount of minutes in a calculation. |
mmatch(value, regex, index_of_matched_value) |
var:value = "[BB2019] Betty Blocks" |
Returns the result of matching a text value against a regex, divided in groups |
modulo(number, divider) |
modulo(21, 5) = 1 |
Returns the remainder after division of one number by another. |
modulo_round(number, divider) |
modulo_round(21, 5) = 25 |
Rounds up the first value, so the modulus returns 0. |
monday_of_week_number(year, weeknumber) |
monday_of_week_number(2019, 1) >>> 2019-01-14 |
Returns the date of the monday of the given week and year |
month(date/datetime) |
month(2019-04-01) >>> 04 |
Returns the month from a specific date as a number expression. |
months(amount) |
2019-04-01 + months(3) >>> 2019-07-01 |
Use a number of months in a calculation. |
newline |
"Hello" + newline + "World" >> Hello \n World |
Inserts a |
nil?(record) |
nil?(var:record.email) >>> true |
Checks if a fields value is empty. Returns |
now |
Date = 01-04-2019 |
Returns the current date and time as a date time expression. |
num_weeks_between_dates(date, date) |
var:date1 = 2019-04-01 |
Returns the difference between given dates, in weeks. |
num_weeks(year) |
var:year = 2019 |
Returns the number of weeks in the given year. |
only_numbers(string) |
only_numbers("a7263s11") >>> 726311 |
Returns all numeric characters from a string. |
parameterize(string) |
parameterize("betty blocks") >>> betty-blocks |
Transforms a string to a parameter, making it a URL-friendly value. |
pow (value, power) |
pow(5, 5) >>> 3125 |
Returns the outcome of |
present? (variable) |
var:record.name = "Robert"
|
Checks if a record or variable exists. Returns |
random (number) |
random(8) >>> 6 |
Returns a random number between |
random_hex (number) |
random_hex(6) >>> bf66d1 |
Generates a random hexadecimal string. The number argument defines the number of characters used for the string. |
random_hex (number) |
random_hex(6) >>> bf66d1 |
Generates a random hexadecimal string. The number argument defines the number of characters used for the string. |
read_file (text_based_file) |
var:file = employees.txt |
Returns the content of a text-based file. |
regex_replace (value, what_to_replace, replace_with_what) |
regex_replace("Betty \n Blocks", "\n", "from the") >> Betty from the Blocks |
Replace a certain value with a different value. You'll need this one to perform a replace on "unreadable characters" and anything with a backslash. These include newlines ( |
replace(value, what_to_replace, replace_with_what) |
replace("Berry Blocks", "r", "t") >> Betty Blocks |
Replace a certain value with a different value. |
rjust(text, number_of_characters) |
rjust("Betty", 10) >>> " Betty" |
Adds a specific number of whitespaces left of a text value, so the width matches the number given in the expression. |
round(number with decimal, number) |
round(99.8) >>> 100 |
Rounds a number with decimal to a whole number, or to a precision equal to the number given as second parameter. |
rsa_decrypt (encrypted_text, private_rsa_key) |
var:value = |
Decrypts encrypted values into plain text through a private RSA-key. |
rsa_encrypt (values, public_rsa_key) |
var:value = Betty Blocks |
Encrypts values into an RSA Message through a public RSA-key.
The text to encrypt must be shorter than the RSA-key.
The maximum size for an RSA-key of 2048 bits is |
sample (collection) |
var:collection = ["Betty", "Blocks", "Alkmaar", "2019"] |
Returns a random object from the collection. |
seconds (number) |
2019-01-04 12:00:00 + seconds(200) >>> 2019-01-04 12:03:20 |
Use an amount of seconds in a calculation. |
sha1 (text) |
sha1("Betty Blocks") >>> b6a6208882a9ab2e097259a2534f7c126bbada4d |
Creates a |
sha256(text) |
sha256("Betty Blocks") >>> 51588c6d5db3a3bcf1a323627f8f6839ed04bf781e5796a855719f7249e6a66c |
Creates a |
sha384 (text) |
sha384("Betty Blocks") >>> 065e413175c0d0989d94982cea6193f7a2bed7acc6a693e0e4bcebc3d1dd7db084309e015f65d231f7539b812b56bb18 |
Creates a |
sha512 (text) |
sha512("Betty Blocks") >>> 619a52f61ccc91a59dbb162c4a203ca544ae02b06f81ba54cc3c055828ee747f48c911df9d9d35cef07264fcd35a610bf8fdfe141a80bb8d848e001469a6c4c0 |
Creates a |
shuffle(collection) |
var:collection = ["Robert", "Marcel", "Ralph", "Jermel"] |
Returns the collection in a random order. |
slice (array, start, length) |
var:array = ["a", "b", "c", "d", "e", "f"] |
Slices an array/collection from the given start value, for the given length. |
split(string, argument) |
split("Betty Blocks Alkmaar", " ") >>> ["Betty", "Blocks", "Alkmaar"] |
Returns an array after splitting a string on an argument/value. |
squeeze (string) |
squeeze("Betty Blocks Alkmaar") >>> Betty Blocks Alkmaar |
Removes double whitespaces from a string. |
starts_with? (string, string) |
starts_with?("Betty", "Be") >>> true |
Checks if a text value starts with the second given text value. Returns |
str(value) |
str(10) + str(10) >>> 1010 |
Converts a value to a string. |
strftime (datetime, format) |
strftime(2019-04-01T07:23:34, "%d/%m/%Y") >>> 01/04/2019 |
Creates a string based on a format applied to a datetime. Use this as a text expression. Note: The return value of
Click here for all date formats. |
string operators |
"Betty" * 3 >>> "BettyBettyBetty" |
Some basic operators also work on strings. You can use a plus ( |
string_to_hash (string) |
var:value = Betty Blocks |
Transforms a string to a hash. |
strip (string) |
strip(" Betty Blocks ") >>> Betty Blocks |
Removes all trailing whitespaces of a string. |
substring (value, start, end) |
substring("Betty Blocks", 5, 11) >>> Block |
Returns characters from a selection of a string. |
sum (array) |
sum([1,2,3]) >> 6 |
Returns the sum of all the values in an array. |
time_in_timezone (datetime, timezone) |
var:date_time = 2019-04-01 10:20:00 |
Returns the given timestamp in a different timezone. |
to_json (text) |
to_json('{[\"key\":\"123\"]}') >>> {["key" : "123"]} |
Transforms text to JSON format. |
today |
Date = 2019-04-01 >>> today >>> 2019-04-01 |
Returns the current date as a date expression. If used as a date time expression, the time will be set to Warning: this expression is no longer functional in the data model expressions. this expression can only be used in action steps for the time being and will be phased out with the "today" time selecter in action expressions in the future. |
transliterate (value) |
transliterate("Bëtty Blöcks") >>> Betty Blocks |
Transliterates |
truncate (string, number_of_characters, trailing_text) |
truncate("Betty Blocks", 8) >>> Betty… |
Shortens a string, closed by trailing text, based on the maximum number of characters. Maximum number includes the trailing text. By default, " |
uniq(array) |
uniq([1,2,2,3]) >>> [1,2,3] |
Removes all double values in an array, returning only unique values. |
upcase(string) |
upcase("betty blocks") >>> BETTY BLOCKS |
Transforms all the letters of a string to uppercase. |
valid?(object) |
var:employee = "employee": { |
Checks if the record or custom model is valid. |
values(hash) |
var:answers = |
Returns a collection of all values in a hash. |
working_days(date, date) |
working_days(2019-04-01, 2019-04-09) >>> |
Calculates all working days between two days. Returns an array of dates. |
weeks (amount) |
2019-05-02 + weeks(2) >>> 2019-05-16 |
Use an amount of weeks in a calculation. |
xml_to_json (xml) |
var:xml = |
Transforms |
xpath (xml, path) |
var:xml = |
Returns the element(s) and their values of an Add Note: Use tools like this xpath generator if you don't want to search for the precise path you need yourself. |
year (date/datetime) |
year(2012-05-01) >>> 2012 |
Returns the year from a specific date as a number expression. |
years (amount) |
today + years(2) |
Give an amount of years for usage in a calculation. |