Formatting strings, dates and currencies

You can format the text, dates and currencies that appear in the messages sent to the user by using system functions in fields such as Send to user. You can also use these on an Action interaction's Set Variable tab to reformat values returned by REST API calls.

Formatting strings

Use these system functions to reformat strings, and add or remove characters from strings:
Examples Returns
system.toUpperCase("Is there anything else?") IS THERE ANYTHING ELSE?
system.toLowerCase("Is there anything else?") is there anything else?
system.toProperCase("proper case") Is There Anything Else?
system.replace("Jack and Jill"," and ") JackJill
system.replace("Jack and Jill"," and ", " why not ") Jack why not Jill
The function system.replace(string, deleteChars, addChars) is case sensitive:
  • string is the string to format.
  • deleteChars is the substring to remove. Only the first match is replaced.
  • addChars is the characters to insert in place of deleteChars. If deleteChars is an empty string (""), the characters are inserted at the beginning of the string.

Enclose each parameter in quotes (single or double).

Examples

For example, in the Send to user of a message, changes the case of the string enclosed in quotes:
Do you want more information about our {system.toProperCase
("product range")}?
Changes the case of the product variable once evaluated:
Do you want more information about our {system.toProperCase
(product)}? 

Formatting and handling dates

Use these system functions to get the date and set the date format.

Examples Returns
system.date.format("ddd MMM Do, YYYY") Tue Jul 31st, 2018
system.date.locale("es"). format("ddd MMM Do, YYYY") mar. jul. 31º, 2018
system.formatDate() July 31st 2018. This is the default format (ddd MMM Do, YYYY)
system.formatDate(system.now, "D/MM/YY") 31/07/18
system.month July
system.day Tuesday
system.year 2018
For example entering the following in Send to user of a message:
Today is {system.formatDate(system.now, "D/MM/YY")}

displays this to the user:

Today is 4/02/19

Formatting currencies

Use the system.formatCurrency() function to set the currency and its format:

system.formatCurrency(value, format, symbol, code)
Where:
  • value is the number to format as currency. By default it will have thousand separators and a decimal point. The default currency is US Dollars.
  • format is a string defining the currency format. For example "%s %v %c" defines a currency value that starts with the currency symbol and ends with the currency name:
    • %s placeholder for the currency symbol, such as €
    • %v placeholder for the numeric value
    • %c placeholder for the currency name, such as EUR
  • symbol is the currency symbol that you want to use (or any other string).
  • code is the name of the currency (or any other string).
For example:
Examples Returns
system.formatCurrency(1000.10) $1,000.10 USD
system.formatCurrency(1000.10, "%s %v %c", "€", "EUR") €1,000.10 EUR