For the complete documentation index, see llms.txt. This page is also available as Markdown.

Functions

If

The if function can be used to swap a simple piece of text out based on whether a condition is true or not. Can also nest these functions.

[| If([Database.City] eq "Akl", "Auckland", "Elsewhere") |]

And/Or

Use these instead of writing a whole bunch of nested if statements

Example of 'And' function

{{ If(|And(eq([merge1], "Yes"), eq([merge2], "Yes"))| is true) }}
 	do this
{{ EndIf }}

Example of 'Or' Function

{{ If(|Or(eq([merge1], "Yes"), eq([merge2], "Yes"))| is True) }}
 	do this
{{ EndIf }} 

String Functions

Length

Checks the Length of the Merge field

Right/Left

Counts in from Left/Right

StartsWith/EndsWith

If a merge starts with or ends with a specific string

Split EndsWith

If a split merge field ends with a specific string

Split Count

Number of items in a split merge field

Substring

Substring(str, start) returns the subString starting at the 0-based index start from str. Substring(str, start, length) returns the length character long subString starting at the 0-based index start from str.

This example was used to format a phone number

Turns "091234567" to this "09 123 4567".


Find/FindX

The find function can search a merge field for a word, phrase, letter, symbol.

The find will return -1 if not found or a zero based index where the subject is found.

The findX function is a regex find and will return the string that matches the suplied regex.

For example, the following will return "5.5":


Cast

Cast is used to change a field type when displayed.

This is helpful when you have a string field that is mobile number and want to format it correctly.

or

  • cast types

  • case "int":

  • case "integer":

  • case "number":

  • case "wholenumber":

return typeof(int);

  • case "real":

  • case "float":

  • case "decimal":

return typeof(double);

  • case "date":

return typeof(DateTime);

  • case "time":

return typeof(TimeSpan);

  • case "yesno":

  • case "bool":

return typeof(bool);

  • case "text":

return typeof(string);

  • case "uniqueidentifier":

return typeof(Guid);


Replace/ReplaceX

Returns replaced string.

Replace Regex

Note: Replace is a string replace whereas ReplaceX is a regex replace.

Replace 2 strings in 1 function

It works from the inside out. So it will replace the inner first, then the outer replace.


Format Functions

Text Transformations

Change text to uppercase

Change text to lowercase

Change to titlecase

Change to smartcase

Smart case works like title case, however also understands RD and PO Box in addresses so will correctly format these.

Encoding

HtmlEncode

This turns html tags into text

URL Encode

URL Decode

Strip Html

Removes all html


Math Functions

The Add/Subtract/Multiply/Divide/Mod can take a floating point but will truncate it before performing the operation so there are also floating point functions that will not do this. All math functions can take any number of arguments.

Add

Adds two numbers together but rounds down to the nearest whole number

Adds two numbers together and does not round the output

Subtract

Subtracts two numbers but rounds down to the nearest whole number

Subtracts two numbers and does not round the output

Multiply

Multiplies two numbers but rounds down to the nearest whole number

Multiplies two numbers and does not round the output

Divide

Divides two numbers but rounds down to the nearest whole number

Divides two numbers and does not round the output

Mod

Between

Returns true if the first number is between the second and third, can be used for dates too

IsOdd

Returns true when its parameter is an odd number; false otherwise.

IsEven

Returns true when its parameter is an even number; false otherwise.

Random

Generates random numbers.

Returns a random floating-point number between 0 (inclusive) and 1 (exclusive):

Returns a random integer between 0 (inclusive) and max (exclusive):

Returns a random integer between min (inclusive) and max (exclusive):

Note: max must not be less than min.


Substring Functions

Length

Checks the Length of the Merge field

Right/Left

Counts in from Left/Right

StartsWith/EndsWith

If a merge starts with or ends with a specific string

Split EndsWith

If a split merge field ends with a specific string

Split Count

Number of items in a split merge field

Substring

Substring(str, start) returns the subString starting at the 0-based index start from str. Substring(str, start, length) returns the length character long subString starting at the 0-based index start from str.

This example was used to format a phone number

Turns "091234567" to this "09 123 4567"


Date Functions

For date functions that take a datePart, the value is one of:

  • Millisecond

  • Second

  • Minute

  • Hour

  • Day

  • Week

  • WeekDay

  • DayOfYear

  • Month

  • Quarter

  • Year

DateAdd

Date is offset by value dateParts

Day before mailout send date

DateDiff

Number of date and time boundaries crossed between startDate and endDate

DateDelta

Number of whole intervals contained within startDate and endDate

DatePart

The requested datePart of date as an integer

Date

The Date component of date

Time

The TimeSpan component of date

Now

Returns the current date and time

Last updated

Was this helpful?