Expressions: Frequently Used Functions
Below is a list of frequently used functions that you can use per data type. Since every application can have a different composition, some functions may not be available in your application (yet).
To find a complete list of all functions in your application, check the data model in the Expression Debugger.
For a fundamental explanation of our expression language and its syntax, you can take a look at Expressions in Novulo.
- Some functions can be applied without context, which takes the form
DataType:function(). These are called static functions;
- Other functions can only be applied to a context object, which is always denoted as
ContextObject.function(). These are called non-static functions. A context object is any result of an expression; a record, a string, an integer, etc.
String functions
Static
|
Function |
Returns |
Explanation |
string: |
join(stringX, list) |
string |
Pastes all values of the list behind eachother, separated by stringX |
Examples; try in the expression debugger!
| Function |
Example |
string:join(stringX, list) |
string:join(" - ",["Hello","world","with","dashes!"]), string:join("".appendnewline(),{persons,first_name,age.isgreater(100)}) |
Non-static
|
Function |
Returns |
Explanation |
stringX. |
appendnewline() |
string |
Adds a line break |
stringX. |
concat(stringY) |
string |
Pastes stringY behind stringX |
stringX. |
contains(stringY) |
boolean |
Checks if stringY appears in stringX |
stringX. |
endswith(stringY) |
boolean |
Checks if stringY appears at the end of stringX |
stringX. |
isinteger() |
boolean |
Checks if stringX can be transformed to an integer |
stringX. |
isnullorempty() |
boolean |
Checks if a string is empty or equal to "" |
stringX. |
length() |
int |
Counts the characters in a string |
stringX. |
replace(stringY, stringZ) |
string |
Replaces all instances of stringY of stringX with stringZ |
stringX. |
startswith(stringY) |
boolean |
Checks if stringY appears at the beginning of stringX |
stringX. |
substring(intX, intY) |
string |
Returns a subset of characters from stringX with length intY, starting at the intX position |
stringX. |
tointeger() |
int |
Transforms stringX into an integer |
stringX. |
tolower() |
string |
Replaces all capital letters in stringX with lowercase letters |
stringX. |
toupper() |
string |
Replaces all lowercase letters in stringX with capital letters |
Examples; try in the expression debugger!
| Function |
Example |
appendnewline() |
"Hello".appendnewline().appendnewline().concat("world!") |
concat(string) |
"Hello".concat(" world!") |
contains(string) |
"Hello world!".contains("hello") |
endswith(stringY) |
"Hello world!".endswith("world!") |
equals(stringY) |
"Hello world!".equals("hello world!") |
isinteger() |
"123".isinteger() |
isnullorempty() |
"".isnullorempty(), see the difference with "".isnull()! |
length() |
"Hello world!".length() |
replace(stringY, stringZ) |
"Hello Novulo!".replace("Novulo!","world!") |
startswith(stringY) |
"Hello world!".startswith("hello") |
substring(intX, intY) |
"I prefer my examples to say Hello world!".substring(28,12) |
tointeger() |
"123".tointeger() |
tolower() |
"HELLO WORLD!".tolower() |
toupper() |
"hello world!".toupper() |
Boolean functions
These are especially useful in filters (in lists, export definitions) and transitions of processes and workflows.
Static
|
Function |
Returns |
Explanation |
boolean: |
not(booleanX) |
boolean |
Returns true if booleanX is false, and vice versa |
boolean: |
and(list) |
boolean |
The list must be a list of boolean expressions. If every expression returns true, the and(list) expression returns true as well. If even one expression returns false, the and(list) expression returns false too! |
boolean: |
or(list) |
boolean |
The list must be a list of boolean expressions. If even one expression returns true, the or(list) expression returns true as well. If every expression returns false, the or(list) expression returns false too! |
Examples; try in the expression debugger!
| Function |
Example |
boolean:not(booleanX) |
boolean:not(int:load(1).add(1).equals(3)) |
boolean:and(list) |
boolean:and(["Hello".equals("hello"), "World!".equals("world!")]) |
boolean:or(list) |
boolean:or(["Hello".equals("goodbye"), "World!".equals("world!")]) |
“Generic” functions
“Generic” of course isn’t a data type. However, some functions can be evaluated in all data types. These are summarized here.
Static
|
Function |
Returns |
Explanation |
DataType: |
if(booleanX, then, else) |
DataType |
Evaluates booleanX: if true, returns the expression in then, if false, returns the expression in else. The else and then expressions must result in the declared DataType |
DataType: |
case(switch, tuplelist, default) |
DataType |
Evaluates switch, then looks up the first matching key in the tuplelist, and returns the accompanied value. If no match is found, default is returned. The values of the tuples must result in the declared DataType. The keys of the tuples must result in the same data type as the switch |
Examples; try in the expression debugger!
| Function |
Example |
DataType:if(booleanX, then, else) |
string:if(boolean:and([date:now().getdayofmonth().equals(1),date:now().getmonth().equals(1)]),"Happy new year!","") |
DataType:case(switch, tuplelist, default) |
string:case(date:now().getmonth().tostring().concat("-") .concat(date:now().getdayofmonth().tostring()), [<"1-1","Happy New Year!">, <"2-14","Happy Valentine's Day!">, <"3-14","Happy Pi Day!">, <"4-1","Happy April Fools' Day!">], "") |
Non-static
|
Function |
Returns |
Explanation |
ContextObject. |
equals(value) |
boolean |
Checks if value is the same as the context object. The value must have the same data type as the context object |
ContextObject. |
isnull() |
boolean |
Checks if the context object is empty |
Examples; try in the expression debugger!
| Function |
Example |
equals(value) |
"Hello".concat(" world!").equals("hello world!"), note that string:getnull().equals(string:getnull()) returns false! Always use .isnull() in stead of .equals(DataType:getnull()) |
isnull() |
string:getnull().isnull(), "".isnull() |
“List” functions
Similarly to the generic functions, these functions are not technically “list” functions. They are all evaluated in some data type and return another data type, but these all have a list as a parameter.
Remember that a list expression comes in the form {DataType, Expression, Filter, Sorting}, or as [Expression1, Expression2, ...etc.] as described here.
The result of the Expression of the list must be the same as the declared data type.
So these are valid:
persons:count({persons, this})
int:count({persons, age()})
string:count({persons, first_name})
While int:count({persons, this}) is not!
Static
|
Function |
Returns |
Explanation |
DataType: |
count(list) |
int |
Counts the values in the list |
DataType: |
exists(list) |
boolean |
Checks if the list has at least one value |
DataType: |
first(list) |
DataType |
Returns the first value in the list |
DataType: |
itemat(list, intX) |
DataType |
Returns the intX-th value in the list |
DataType: |
min(list) |
DataType |
Returns the lowest value in the list |
DataType: |
max(list) |
DataType |
Returns the highest value in the list |
DataType: |
sum(list) |
DataType |
Sums the values in the list |
Examples; try in the expression debugger!
| Function |
Example |
count(list) |
persons:count({persons, this}), int:count({persons, age()}), string:count({persons, first_name}) |
exists(list) |
persons:exists({persons,this,age().isgreater(100)}) |
first(list) |
persons:first({persons, this, age().isnotnull(), birthday.addyears(age()).getdaysto(date:now()).desc}) |
Non-static
|
Function |
Returns |
Explanation |
DataType: |
in([list]) |
boolean |
Checks if the value appears in the list |
Examples; try in the expression debugger!
| Function |
Example |
in([string]) |
"world".in(["Hello Novulo!", "Hello world!"]) |