String Formatting
Last updated
Last updated
CrossEngage offers two string formatting functions:
trim
- used to remove whitespace around a string
substring
- used to display a substring of an existing string
The trim
helper function removes white spaces from the start and end of a string. The syntax of this formatting function is:
For the example below, we use john.doe@crossengage.io
as the value of the user's email attribute.
Once the function is evaluated, it displays john.doe@crossengage.io
in the section where it is used in the message.
Using the helper function #findProduct
, we search for a particular sku
and format the result's [properties.name]
attribute. For the example below, we use iPhone 8 Plus
as the value of the product's name.
Once the function is evaluated, it displays iPhone 8 Plus
in the section where it is used in the message.
To extract a substring from a text field, we can use the substring
function. This can be quite useful in breaking down text fields such as address, IBAN, or Business Unit, where different parts of the string might have Independent meaning.eaning.
Property
Description
attribute
Any user or event attribute or any information extracted through any of the helper functions. e.g. {{user.[traits.email}}
Property
Description
propertyName
Required. Any user or event attribute or any information extracted through any of the helper functions.
start
Required. The index of the character in the original string where the substring starts. e.g. 1
refers to the first character in the string, 3
to the third character.
length
Required. The number of characters the substring extracts from the original string. e.g. 10