Expression Reference

Expressions are pieces of custom functionality which you can use in several places in your app, e.g. as an expression property in a model.

Written by Robert van Boesschoten Updated over a week ago

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.

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

Below is an overview of all expressions in Betty Blocks, in alphabetical order.

any_blank?(array)

Checks if there are blank values in the collection. Returns true or false.

generate_uuid()

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.

hmac_sha256(text, secret)

Creates a hmac_sha256 hash 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_sha384(text, secret)

Creates a hmac_sha384 hash 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_sha512(text, secret)

Creates a hmac_sha512 hash 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.

read_file(file)

regex_replace(value, what_to_replace, replace_with_what)

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 (\n), tabs (\t) and carriage returns (\r).

transliterate(value)

truncate(string, number_of_characters, trailing_text)

Shortens a string, closed by trailing text, based on the maximum number of characters. Maximum number includes the trailing text. By default, "..." is used as trailing text. By including a third parameter, you can choose your own trailing text.