Functions are written in a specific format that allows the information to be interpreted and executed as a series of commands or code.

Function components​

Functions are written using the following syntax:

<%${library:function_name(argument1,argument2,...)}%>
Syntax elementDescription
Information returned by a function

Information returned by a function can be inserted into a message using the placeholders <% %>.

PlaceholderThe placeholder ${ } defines the beginning and end of the string of characters that are interpreted by the system as code. Inside this placeholder, you can include a single function, a series of nested functions, operators, and comparative values.
FunctionThe function itself is written with the format library:function_name.
Parameters 

Parameters required by the function are set in parentheses following the function name, i.e.: (argument1,argument2,...).



Formatting parameters​

The format of the values used as parameters varies based on the source and type of data.


  • Static values:
    • Static string values are set in single quotes.
    • Operators (e.g., ‘<=’), comparison values (e.g., ‘empty,’ ‘null’), and static Boolean values ('true,' ‘false’) are also set in single quotes when used inside a function as parameters.
    • Static numeric values are entered without quotes.

  • Attributes: Data stored in an attribute is referenced using the attribute type followed by the name of the attribute set first in single quotes and then in square brackets.

    Example

    A custom attribute called 'Destination' is referenced as follows:  user.customAttribute['Destination']

  • Linked related data sets: Data stored in a linked related data set is referenced in a similar format to an attribute value. The reference begins with the attribute type user.relatedAttribute, followed by the name of the data set and the name of the column to be used by the function. The data set, and column names are set first in single quotes and then in square brackets.

    Example

    A related data set linked to the user attribute 'user.Email' called 'Orders' with a column 'TotalPrice' is referenced as follows:  user.relatedAttribute['Orders']['TotalPrice']

  • Unlinked related data sets: Data stored in an unlinked related data set requires the use of an additional function (ecx:related) to identify the value to be used as a key.

    Example

    An unlinked related data set that uses the email address as a key called 'OrderTotalsPerCustomer' with a column 'TotalOrderValue' is referenced as follows:  ecx:related('OrderTotalsPerCustomer', user['Email'])['TotalOrderValue']