List of Experlogix Template Builder functions
The Experlogix Template Builder offers a large number of functions that you can use in your expressions. Use the expression tables below to power your Templates with additional functionality via expressions.
Regular expressions
Some of the functions you can use allow you to use regular expressions. To learn more about regular expressions, refer to Java Tutorials.
Extended characters
Some of the functions you can use allow you to use extended characters. To learn more about extended characters, refer to Control character.
Basic Functions
Characters |
Description |
---|---|
\n |
Newline |
\r |
Carriage return |
\t |
Tab |
\\ |
Backslash |
\x## |
Hexadecimal value (between 00 and FF) |
\u#### |
Extended hexadecimal value meant for Unicode characters (between 0000 and FFFF) |
\d### |
Decimal value (between 000 and 255) |
Mathematical functions
Elementary arithmetic
Function name |
Description |
Syntax |
Example |
---|---|---|---|
Copy
|
Returns the sum of c and b (c + b). |
add(c, b) |
add('1.2', '2.3') = 3.5 add('1.2', 2.3) = 3.5 add(1.2, 2.3) = 3.5 |
Copy
|
Returns the sum of c and 1 (c + 1). |
uadd(c) |
uadd(10) = 11 |
Copy
|
Returns the result of subtracting b from c (c - b). |
sub(c, b) |
sub(9,3) = 6 sub(3,9) = -6 |
Copy
|
Returns the result of dividing c by b (c / b). |
div(c, b) |
div(9,2) = 4.5 div(-9,2) = -4.5 div(2,4) = 0.5 |
Copy
|
Returns the remainder of the division of c and b. |
mod(c, b) |
mod(9,2) = 1 mod(9,3) = 0 mod(8,3) = 2 mod(-9,-2) = -1 |
Copy
|
Returns the multiplication of c with b (c × b). |
mult(c, b) |
mult(2,6.5) = 13 mult(-2,8) = -16 |
Copy
|
Returns the sum of all arguments (a + b + c + d...). |
sum(a, b, c, d...) |
sum(1,6.5,2) = 9.5 sum(1,0,0,0,6) = 7 |
Copy
|
Returns the product of all arguments (a x b x c x d...). |
prod(a, b, c, d...) |
prod(2,3,4) = 24 prod(-2,1,-3.5,2) = 14 |
Basic
Function Name |
Description |
Synta |
Example |
---|---|---|---|
Copy
|
Returns a new random number between 0.0 and 1.0. Seed is the number used to initialize a pseudo-random number generator. The seed is not required. |
rnd(seed) |
rnd(25) = 0.645 |
Copy
|
Returns the absolute value of c (|c|). |
abs(c) |
abs(123) = 123 abs(-123) = 123 |
Copy
|
Returns the largest number of c and b. |
max(c, b) |
max(5,2) = 5 max(-3,7) = 7 max(-3,-5) = -3 |
Copy
|
Returns the smallest number of c and b. |
min(c,b) |
min(5,2) = 2 min(-3,7) = -3 min(-3,-5) = -5 |
Copy
|
Returns c multiplied with -1. |
negate(c) |
negate(63) = -63 negate(-63) = 63 |
Copy
|
Returns -1 if c is negative, 1 if c is positive, and 0 if c is 0. |
sign(c) |
sign(0) = 0 sign(-4) = -1 sign(7) = 1 |
Copy
|
Converts c to a floating point value. |
val(c) |
val(1.2) = 1.2 |
Power
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
Copy
|
Returns the square root of c. |
sqrt(c) |
sqrt(121) = 11 sqrt(499849) = 707 |
Copy
|
Returns the square of c (c²). |
sqr(c) |
sqr(11) = 121 sqr(707) = 499849 |
Copy
|
Returns e raised to the power c. |
exp(c) |
exp(2) = 7.389 |
Copy
|
Returns c raised to the power b (c ^ b). |
pow(c, b) |
pow(10,3) = 1000 pow(2,8) = 256 pow(3,3) = 27 |
Logarithms
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
Copy
|
Returns the natural logarithm of c (base e). |
ln(c) |
ln(10) = 2.303 |
Copy
|
Returns the logarithm of c in base 10. |
log(c) |
log(1000) = 3 log(100) = 2 |
Copy
|
Returns the logarithm of c in base 2. |
log(c) |
log2(1024) = 10 log2(256) = 8 |
Copy
|
Returns the logarithm of c in base n. |
logn(c, n) |
logn(343,7) = 3 logn(64,4) = 3 logn(100,10) = 2 |
Rounding
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
Copy
|
Returns the smallest integer higher than or equal to c (rounding up). |
ceil(c) |
ceil(1.0) = 1 ceil(1.1) = 2 ceil(1.8) = 2 ceil(-1.0) = -1 ceil(-1.1) = -1 |
Copy
|
Returns the largest integer lower than or equal to c (rounding down). |
floor(c) |
floor(1.0) = 1 floor(1.1) = 1 floor(2.5) = 2 floor(-1.0) = -1 floor(-1.3) = -2 |
Copy
|
Returns c without the decimal part. |
trunc(c) |
trunc(1.0) = 1 trunc(1.6) = 1 trunc(2.5) = 2 trunc(-3.6) = -3 |
Copy
|
Returns c rounded to the nearest integer. |
round(c) |
round(1.0) = 1 round(1.2) = 1 round(1.5) = 1 round(1.7) = 2 |
Copy
|
Returns c rounded to a number of decimal places (b). |
roundDecimal(c,b) |
round(2.12355,3) = 2.124 round(2.12555,3) = 2.126 round(2.12555,2) = 2.13 round(2.12555,1) = 2.1 |
Trigonometrical
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
Copy
|
Returns the sine of c (c in degrees). |
sin(c) |
sin(0) = 0 sin(30) = 0.5 sin(45) = 0.707 sin(90) = 1 |
Copy
|
Returns the cosine of c (c in degrees). |
cos(c) |
cos(0) = 1 cos(45) = 0.707 cos(60) = 0.5 cos(90) = 0 |
Copy
|
Returns the tangent of c. (c in degrees). |
tan(c) |
tan(0) = 0 tan(45) = 1 tan(60) = 1.732 |
Counting
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
Copy
|
Returns the average of all the arguments. Blank values are not included. |
avg(a,b,c...) |
|
Copy
|
Returns the average of all the arguments. Blank values are included and considered to be zero. |
avga(a,b,c...) |
|
Copy
|
Returns the median of all the arguments. Blank values are not included. |
median(a,b,c...) |
median(1,5,7) = 5 median(3,6,18) = 6 median(3,6,8,11) = 7 |
Copy
|
Returns the median of all the arguments except x. Blank values get the value x. |
mediana(x,a,b,c...) |
|
Copy
|
Returns the number that most often appears in the arguments. Blank values are not included. |
mode(a,b,c...) |
mode(1,2,2,3) = 2 mode(1,2,2,3,3) = no mode mode(1,2,2,3,3,3) = 3 |
Copy
|
Returns the number that most often appears in the arguments except x. Blank values get the value x. |
modea(x,a,b,c...) |
|
Copy
|
Counts the number of values. Blank values are not included. |
count(a,b,c...) |
|
Copy
|
Counts the number of values. Blank values are included. |
counta(a,b,c...) |
|
Copy
|
Counts the number of blank values. |
countb(a,b,c...) |
|
Copy
|
Counts the number of distinct values. Blank values are not included. |
countDistinctValues(a,b,c...) |
countDistinctValues(a,a,a,b,b) = 2 countDistinctValues(a,b,c,c,c,c) = 3 |
Copy
|
Counts the number of distinct values. Blank values are included. |
countDistinctValues(a,b,c...) |
|
Text functions
Basic
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
str |
Converts c to a string. |
str(c) |
str(1.2) = 1.2 |
strlen |
Returns the length of c. |
strlen(c) |
strlen('Hello world!') = 12 strlen('Xpertdoc') = 8 |
concat |
Returns the string that results from concatenating c and b. You can use more than two arguments. |
concat(c, b) |
concat('Hello ', 'world') = 'Hello world' concat('Hi ','there ','everyone') = 'Hi there everyone' |
substr |
Returns the sub-string of s starting from c with length b. |
substr(s, c, b) |
substr('Hello World!', 1, 4) = 'ello' substr('Hello World!', 3, 2) = 'lo' substr('Hello World!', 3, -2) = 'el' substr('Hello World!', 100, -4) = 'rld!' |
chr |
Returns the nth character of c. |
chr(c, n) |
chr('Xpertdoc', 2) = 'p' chr('Xpertdoc', 150) = '' |
Trim
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
trim |
Removes all leading and trailing whitespaces from c. |
trim(c) |
trim(' some text ') = 'some text' |
rtrim |
Removes all trailing whitespaces from c. |
rtrim(c) |
rtrim(' some text ') = ' some text' |
ltrim |
Removes all leading whitespaces from c. |
ltrim(c) |
ltrim(' some text ') = 'some text ' |
Case
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
toLower / lowercase |
Returns c with all characters in lowercase. |
|
toLower('Xpertdoc') = 'xpertdoc' lowercase('Xpertdoc') = 'xpertdoc' |
toUpper / uppercase |
Returns c with all characters in uppercase. |
|
toUpper('Xpertdoc') = 'XPERTDOC' uppercase('Xpertdoc') = 'XPERTDOC' |
capitalizeEachWord |
Returns c where each word has a capital first letter. |
capitalizeEachWord(c) |
capitalizeEachWord('this is very good.') = 'This Is Very Good.' |
sentenceCase |
Returns c where each sentence is capitalized. |
sentenceCase(c) |
sentenceCase('hi there. we are going to start.') = 'Hi there. We are going to start.' |
toggleCase |
Returns c where each letter's case is inverted. |
toggleCase(c) |
toggleCase('This is a strange function according to Dr. Strangefunction.') = 'tHIS IS A STRANGE FUNCTION ACCORDING TO dR. sTRANGEFUNCTION.' |
Replace
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
replaceText |
Returns a string where each occurrence of d in c has been replaced with e. Case is ignored. |
replaceText(c, d, e) |
replaceText('The quick brown fox jumps over the lazy dog', 'brown', 'orange') = 'The quick orange fox jumps over the lazy dog' replaceText('The quick brown fox jumps over the lazy dog', 'BROWN', 'ORANGE') = 'The quick ORANGE fox jumps over the lazy dog' replaceText('The quick BROWN fox jumps over the lazy dog', 'brown', 'orange') = 'The quick orange fox jumps over the lazy dog' replaceText('The quick brown fox jumps over the lazy dog', 'brown', '') = 'The quick fox jumps over the lazy dog' |
replaceTextC |
Returns a string where each occurrence of d in c has been replaced with e. Case-sensitive. |
replaceTextC(c, d, e) |
replaceTextC('The quick brown fox jumps over the lazy dog', 'brown', 'orange') = 'The quick orange fox jumps over the lazy dog' replaceTextC('The quick brown fox jumps over the lazy dog', 'BROWN', 'ORANGE') = 'The quick brown fox jumps over the lazy dog' replaceTextC('The quick BROWN fox jumps over the lazy dog', 'brown', 'orange') = 'The quick BROWN fox jumps over the lazy dog' replaceTextC('The quick brown fox jumps over the lazy dog', 'brown', '') = 'The quick fox jumps over the lazy dog' |
replaceExtended |
Returns a string where each occurrence of d in c has been replaced with e. d and e are considered to be texts with extended characters. Case is ignored. |
replaceExtended(c, d, e) |
replaceExtended('"??"', '\u0100', 'Latin capital letter A with macron') = '"Latin capital letter A with macron"' |
replaceExtendedC |
Returns a string where each occurrence of d in c has been replaced with e. d and e are considered to be texts with extended characters. Case-sensitive. |
replaceExtendedC(c, d, e) |
replaceExtendedC('"??"', '\u0100', 'Latin capital letter A with macron') = '"Latin capital letter A with macron"' |
replaceRegEx |
Returns a string where each occurrence of d in c has been replaced with e. d and e are considered to be regular expressions. |
replaceRegEx(c, d, e) |
replaceRegEx('The quick brown fox jumps over the lazy dog', '(dog|fox)', '\[animal\]$1\[animal\]') = 'The quick brown [animal]fox[animal] jumps over the lazy [animal]dog[animal]' |
Split
If you use any of the split functions, you need to configure it using the following steps:
1. | Create a pseudo-field where you use the split function on a field. |
2. | Loop over the pseudo-field in your template. |
3. | In the loop, map the pseudo-field again. If your field is called Address1, this is what you'll end up with: |
If you do not loop, you'll only get the first item instead of all the items.
Function Name |
Description |
Example |
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
split |
Splits a field into separate parts, which can be stored as an array in a pseudo-field. These can then be accessed by mapping the pseudo-field split(text, separator, isRegex, removeEmpty, trimParts).
|
|
||||||||||||
splitLines |
Splits a field into separate parts, splitting on newlines splitLines(text). This function is equivalent to split(text, '\\r?\\n', 1, 0, 0) and will split text into pieces separated by a newline. |
|
||||||||||||
splitWords |
Splits a field into separate parts, splitting on whitespaces splitWords(text). This function is equivalent to split(text, '\\\\s+', 1, 1, 1) and will split text into pieces separated by whitespaces. |
|
Format
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
formatNumber |
Output a number in a given pattern. For more information, refer to Number patterns. |
formatNumber(number,pattern) |
formatNumber(500,'0.00') = 500.00 formatNumber(200,'##.##') = 200 |
formatNumberR |
Output a number in a given pattern, using a certain locale. For more information, see Number patterns and List of supported locales. |
formatNumber(number,pattern,locale) |
formatNumberR(500,'¤0.00','en_us') = $500.00 formatNumberR(500,'¤0.00','nl_be') = €500,00 |
Date & time functions
For details on Date & time functions, please refer to the following pages
Logical functions
Logic
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
if |
Returns d if c equates to true, e if c equates to false. |
if(c, d, e) |
if(1, yes, no) = yes if(0, yes, no) = no if(2, yes, no) = yes if(-1, yes, no) = yes |
and |
Returns the logical AND of c and d. |
and(c, d) |
and(1, 1) = 1 and(1, 0) = 0 and(0, 1) = 0 and(0, 0) = 0 |
or |
Returns the logical OR of c and d. |
or(c, d) |
or(1, 1) = 1 or(1, 0) = 1 or(0, 1) = 1 or(0, 0) = 0 |
not |
Returns 1 if c is 0, 0 otherwise. |
not(c) |
not(0) = 1 not(1) = 0 not(2) = 0 not(-1) = 0 |
Comparison
Function Name |
Description |
Syntax |
Example |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eq |
Returns 1 if c is equal to d, 0 otherwise. When used with text, the values are trimmed (trailing and leading whitespaces are removed), and case is ignored. |
eq(c, d) |
eq(2, 2) = 1 eq(2, 5) = 0 eq(2.0, 2) = 0 eq(' AbC ','abc') = 1 |
||||||||||||||
neq |
Returns 1 if c is not equal to d, 0 otherwise. When used with text, the values are trimmed (trailing and leading whitespaces are removed), and case is ignored. |
neq(c, d) |
eq(2, 2) = 0 eq(2, 5) = 1 eq(2.0, 2) = 1 eq(' AbC ','abc') = 0 |
||||||||||||||
neq |
Extensions of eq and neq. The eq and neq functions can be extended for use with text:
|
|
|
||||||||||||||
gt |
Returns 1 if c is bigger than d, 0 otherwise. |
gt(c, d) |
gt(2, 1) = 1 gt(2, 5) = 0 gt(2, 2) = 0 |
||||||||||||||
geq |
Returns 1 if c is bigger than or equal to d, 0 otherwise. |
geq(c, d) |
geq(2, 1) = 1 geq(2, 5) = 0 geq(2, 2) = 1 |
||||||||||||||
lt |
Returns 1 if c is lower than d, 0 otherwise. |
lt(c, d) |
lt(2, 1) = 0 lt(2, 5) = 1 lt(2, 2) = 0 |
||||||||||||||
leq |
Returns 1 if c is lower than or equal to d, 0 otherwise. |
leq(c, d) |
leq(2, 1) = 0 leq(2, 5) = 1 leq(2, 2) = 1 |
||||||||||||||
hasBlanks |
Returns 1 when at least one of the arguments is blank. |
hasBlanks(a,b,c...) |
|
||||||||||||||
isNull |
Returns 1 when c is unspecified (null). |
isNull(c) |
|
||||||||||||||
isNullOrBlank |
Returns 1 when c is unspecified (null) or blank (empty or only whitespaces). |
isNullOrBlank(c) |
|
Check text
Function Name |
Description |
Syntax |
Example |
---|---|---|---|
contains |
Returns 1 if c contains s, 0 if it doesn't. Case is ignored. |
contains(c, s) |
contains('Xpertdoc', 'Xp') = 1 contains('Xpertdoc', 'xP') = 1 contains('Xpertdoc', 'Xu') = 0 contains('Xpertdoc', 'u') = 0 |
containsc |
Returns 1 if c contains s, 0 if it doesn't. Case-sensitive. |
containsc(c, s) |
containsc('Xpertdoc', 'Xp') = 1 containsc('Xpertdoc', 'xP') = 0 containsc('Xpertdoc', 'Xu') = 0 containsc('Xpertdoc', 'u') = 0 |
startsWith |
Returns 1 if c starts with s, 0 if it doesn't. Case is ignored. |
startsWith(c, s) |
startsWith('Xpertdoc', 'xp') = 1 startsWith('Xpertdoc', 'X') = 1 startsWith('Xpertdoc', 'oc') = 0 startsWith('Xpertdoc', 'Oc') = 0 |
startsWithC |
Returns 1 if c starts with s, 0 if it doesn't. Case-sensitive. |
startsWithC(c, s) |
startsWithC('Xpertdoc', 'xp') = 0 startsWithC('Xpertdoc', 'X') = 1 startsWithC('Xpertdoc', 'oc') = 0 startsWithC('Xpertdoc', 'Oc') = 0 |
endsWith |
Returns 1 if c ends with s, 0 if it doesn't. Case is ignored. |
endsWith(c, s) |
endsWith('Xpertdoc', 'xp') = 0 endsWith('Xpertdoc', 'X') = 0 endsWith('Xpertdoc', 'oc') = 1 endsWith('Xpertdoc', 'Oc') = 1 |
endsWithC |
Returns 1 if c ends with s, 0 if it doesn't. Case-sensitive. |
endsWithC(c, s) |
endsWithC('Xpertdoc', 'xp') = 0 endsWithC('Xpertdoc', 'X') = 0 endsWithC('Xpertdoc', 'oc') = 1 endsWithC('Xpertdoc', 'Oc') = 0 |
Other
Function Name |
Description |
Syntax |
Example |
||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
getLoopIndex |
Returns the number of the current iteration, with the first iteration being 0. This can be useful in loops. Example: making your own numbered lists. |
getLoopIndex() |
If you have nested loops, you can get a higher level loop's current iteration by specifying how many levels up you want to look. For instance, if you have loops A, B and C where C is inside B and B is inside A:
|
||||||||
safeValue |
Returns c unless an error occurs, in which case d is returned. If d is not specified, null is used. This function can be useful when you cannot guarantee that the value will be what you need. For instance, further calculations expect a number, but the field may also hold a string. Using this function guarantees that the document generation continues - it may not be with the expected result, but at least you can catch this instead of running into an error. |
safeValue(c,d) |
|
||||||||
valueOrDefault |
Returns c unless it is null, in which case d is returned. This function can be useful when you must avoid null values. Null values are, for instance, empty fields (for numbers or dates). |
valueOrDefault(c,d) |
|