Function Syntax and Formatting
    • 1 Minute to read
    • Dark
      Light

    Function Syntax and Formatting

    • Dark
      Light

    Article summary

    Introduction

    Functions follow a specific syntax that allows data to be interpreted and executed as commands or code. This guide explains function structure, parameters, and data formatting.

    Function Structure

    Functions use the following format:

    <%${library:function_name(argument1, argument2, ...)}%>

    Key Syntax Elements

    Element

    Description

    Placeholder

    <% %> encloses function results to be inserted into a message.

    Code Block

    ${ } defines the section interpreted by the system as code. It can contain functions, nested functions, operators, and comparison values.

    Function

    Written in the format library:function_name.

    Parameters

    Enclosed in parentheses (argument1, argument2, ...) and required by the function.

    Formatting Parameters

    Parameter values vary depending on their source and type.

    Static Values

    • String Values: Enclosed in single quotes ('example').

    • Operators & Comparisons: ('<=', 'empty', 'null') enclosed in single quotes.

    • Boolean Values: 'true', 'false' (in single quotes).

    • Numeric Values: Entered without quotes (1234).

    Referencing Data

    Functions can retrieve values from different data sources, including attributes and related data sets.

    Attributes

    • Referenced using the format:

      user.customAttribute['AttributeName']

      Example:

      user.customAttribute['Destination']

    Linked Related Data Sets

    • Referenced similarly to attributes, using:

      user.relatedAttribute['DataSetName']['ColumnName']

      Example:

      user.relatedAttribute['Orders']['TotalPrice']

      Retrieves the TotalPrice from the Orders dataset linked to user.Email.

    Unlinked Related Data Sets

    • Requires the ecx:related function to identify values using a key.

      ecx:related('DataSetName', user['KeyAttribute'])['ColumnName']

      Example:

      ecx:related('OrderTotalsPerCustomer', user['Email'])['TotalOrderValue']

      Retrieves TotalOrderValue from OrderTotalsPerCustomer using user.Email as the key.


    Was this article helpful?

    What's Next
    ESC

    AI Assistant, facilitating knowledge discovery through conversational intelligence