Get started with Helper functions

Last update: 2025-04-07
  • Created for:
  • Experienced
    Developer

Use Journey Optimizer templating language to perform operations on data, such as calculations, data formatting or conversions, conditions, and manipulate them in the context of personalization. Learn personalization syntax guidelines on this page.

➡️ Learn how to use helper functions in this video

Templating language is leveraged in helper functions available in personalization drop-down list of the personalization editor, as below:

NOTE

The functions and capabilities available in the personalization editor differ from the ones available in the Journey advanced expression editor.

In the Journey Optimizer personalization editor, helper functions are grouped into three categories: Functions, Helpers and Operators.

Select a category, to access sub-categories and functions.

Access to sub-categories by clicking the > icon. Select a function by clicking on the + icon: the function is automatically added to the personalization screen.

Click the ... icon to view the description of the function and add it to your favorites. Learn more

Functions

Aggregation and Array Functions

AverageThis function returns the arithmetic mean of all the selected values within the array
CountThis function returns the number of elements within the given array
Count Only NullThis function counts the number of null values in the list.
Count With NullThis function counts all the elements of the list including null values
DistinctThis function gets values from an array or a list with duplicate values removed
Distinct Count With NullThis function counts the number of different values including the null values
First itemThis function returns the first item in an array or a list
First n in arrayThis function returns the first `N` items in an array, when sorted in ascending order based on the given numerical expression
InThis function is used to determine if an item is a member of an array or list
IncludesThis function determines if an array or list contains a given item
IntersectsThis function determines if two arrays or lists have at least one common member
Last n in arrayThis function returns the last `N` items in an array, when sorted in ascending order based on the given numerical expression
MaximumThis function returns the largest of all the selected values within an array
MinimumThis function returns the smallest of all the selected values within the array
Not inThis function determines if an item is not a member of an array or list
Subset ofThis function determines if a specific array (array A) is a subset of another array (array B), i.e. if all elements in array A are elements of array B
SumThis function returns the sum of all the selected values within the array
Superset ofThis function determines if a specific array (array A) is a superset of another array (array B), i.e. if that array A contains all elements in array B

Date Time Functions

Add DaysThis function adjusts a given date by a specified number of days, using positive values to increment and negative values to decrement.
Add HoursThis function adjusts a given date by a specified number of hours, using positive values to increment and negative values to decrement.
Add MinutesThis function adjusts a given date by a specified number of minutes, using positive values to increment and negative values to decrement.
Add MonthsThis function adjusts a given date by a specified number of months, using positive values to increment and negative values to decrement.
Add SecondsThis function adjusts a given date by a specified number of seconds, using positive values to increment and negative values to decrement.
Add YearsThis function adjusts a given date by a specified number of years, using positive values to increment and negative values to decrement.
AgeThis function retrieves the age from a given date.
Age In DaysThis function calculates the age of a given date in days, i.e. the number of days elapsed between the given date and the current date, negative for future dates and positive for past dates.
Age In MonthsThis function calculates the age of a given date in months, i.e. the number of months elapsed between the given date and the current date , negative for future dates and positive for past dates.
Compare DatesThis function compares the first input date with the other. Returns 0 if date1 is equal to date2, -1 if date1 comes before date2 and 1 if date1 comes after date2.
Convert ZonedDateTimeThis function converts a date-time to a given timezone.
Current time in millisecondsThis function retrieves current time in epoch millisecond.
Date differenceThis function retrieves the difference between two dates in number of days.
Day of monthThis function returns the number representing the day of the month.
Day of weekThis function retrieves the day of week.
Day of yearThis function retrieves the day of year.
Diff In SecondsThis function returns the difference between two dates in terms of seconds.
Extract HoursThis function extracts the hour component from a given timestamp.
Extract MinutesThis function extracts the minute component from a given timestamp.
Extract MonthsThis function extracts the month component from a given timestamp.
Extract SecondsThis function extracts the second component from a given timestamp.
Format dateThis function formats a date time value.
Format date with locale supportThis function formats a date time value into its corresponding language sensitive representation, i.e in a desired locale.
Get CurrentZonedDateTimeThis function returns the current date and time with time zone information.
Hours DifferenceThis function returns the difference between two dates in terms of hours.
Minutes DifferenceThis function returns the difference between two dates in terms of minutes.
Months DifferenceThis function returns the difference between two dates in terms of months.
Set DaysThis function sets the day of the month for the given date-time.
Set HoursThis function sets the hour of the date-time.
To Date TimeThis function converts string to date. It returns the epoch date as output for invalid input.
To UTCThis function converts a datetime to UTC.
Truncate to Start Of DayThis function modifies a given date-time by setting it to the start of the day with the time set to 00:00.
truncateToStartOfQuarterThis function truncates a date-time to the first day of its quarter (e.g., Jan 1, Apr 1, Jul 1, Oct 1) at 00:00.
truncateToStartOfWeekThis function modifies a given date-time by setting it to the start of the week(Monday at 00:00).
truncateToStartOfYearThis function modifies a given date-time by truncating it to the first day of the year (January 1st) at 00:00.
Week of yearThis function returns the week of the year
Years DifferenceThis function returns the difference between two dates in terms of years.

Map Functions

GetThis function is used to retrieve the value of a map for a given key
KeysThis function is used to retrieve all the keys for a given map
ValuesThis function retrieves all the values of a given map

Math Functions

AbsoluteThis function formats any number into its language-sensitive representation.
Format numberThis function formats any number into its language-sensitive representation.
RandomThis function returns a random value between 0 and 1
Round downThis function rounds down a number
Round upThis function rounds up a number
To hex stringcconverts any number into its hexadecimal string.
ToIntConverts any of these types (number, double, int, long, float, short, byte, boolean, string) into an integer.
To percentageThis function converts a number to percentage
To precisionThis function converts a number to required precision
To stringThis function converts any number into its string representation.

Object Functions

Is not nullThis function is used to determine if an object reference exists
Is nullThis function is used to determine if an object reference does not exist

String Functions

Camel CaseThis function is used to capitalize the first letter of each word of a string
Char code atThis function returns ASCII value of a character, like the charCodeAt function in JavaScript
ConcatThis function is used to combine two strings into one
ContainsThis function is used to determine if a string contains a specified substring
Does not containThis function is used to determine if a string does not contain a specified substring
Does not end withThis function is used to determine if a string does not end with a specified substring
Does not start withThis function is used to determine if a string does not start with a specified substring
Encode 64This function is used to encode a string
Ends withThis function is used to determine if a string ends with a specified substring
EqualsThis function is used to determine if a string does not start with a specified substring, with case sensitivity
Equals Ignore CaseThis function is used to determine if a string does not start with a specified substring, without case sensitivity
Extract Email DomainThis function is used to extract the domain of an email address
Format currencyThis function converts any number into its corresponding language-sensitive currency representation depending on the locale passed as a string in the second argument
Get url hostThis function is used to get url host.
Get url pathThis function is used to get url path
Get url protocolThis function is used to get url protocol
Index OfThis function returns the position (in the first argument) of the first occurrence of the second parameter. Returns -1 if there is no match
IsEmptyThis function is used to check if a string or expression is empty.
Is Not EmptyThis function returns true if the string in the parameter is not empty.
Last Index OfThis function returns the position (in the first argument) of the last occurrence of the second parameter. Returns -1 if there is no match.
Left trimThis function removes white spaces from beginning of a string
LengthThis function is used to get the number of characters in a string or an expression
LikeThis function is used to determine if a string matches a specified pattern
Lower CaseThis function converts a string to lower case letters
MaskThis function is used to replace a part of a string with "X" characters.
MatchesThis function is used to determine if a string matches a specific regular expression
MD5This function returns md5 hash of input string.
Not equal toThis function is used to determine if a string is not equal to the specified string
Not Equal With Ignore CaseThis function compares two strings ignoring case.
Regular expression groupThis function is used to extract specific information, based on the regular expression provided
ReplaceThis function replaces a given substring in a string with another substring
Replace allThis function replaces all substrings of a text that matches the "target" with the specified literal "replacement" string
Right trimThis function removes white spaces from end of a string
SplitThis function is used to split a string by a given character
Starts withThis function is used to determine if a string starts with a specified substring
String to dateThis function converts a string value into a date-time value
String to integerThis function Converts a string value into an integer value.
String to numberThis function is used to convert a string into number. It returns the same string as output for invalid input.
Sub stringThis function returns the sub-string of the string expression between the begin index and the end index.
Title CaseThis function is used to capitalize first letters of each word of a string
To BoolThis function Converts an argument value into a boolean value, depending on its type.
To Date TimeThis function is used to convert string to date. It returns the epoch date as output for invalid input.
To Date Time onlyThis function converts an argument value into a date time only value. It returns the epoch date as output for invalid input.
TrimThis function removes white spaces from the beginning and from end of a string
Upper caseThis function converts a string to upper case letters
Url decodeThis function is used to decode a url encoded string.
Url encodeThis function is used to url encode a string.

Helpers

Helpers are detailed on this page.

Default fallback valueThis function is used to render a variable with default
EachThis function is used to iterate over an array
IfThis function is used to define a conditional block - if the expression evaluation returns true, the block is rendered
LetThis function allows an expression to be stored as a variable to be used later in a query
UnlessThis function is used to define a conditional block - if the expression evaluation returns false, the block is rendered
WithThis function is used to change the evaluation token of template-part

Operators

Arithmetic functions

Arithmetic functions are used to perform basic calculations on values.

AdditionThis operator is used to find the sum of two argument expressions
DivideThis operator is used to find the quotient of two argument expressions
MultiplicationThis operator is used to find the product of two argument expressions
Remainder This operator is used to find the remainder after dividing the two argument expressions
Subtraction This operator finds the difference between two expressions

Boolean functions

Boolean functions are used to perform boolean logic on different elements.

AndThis operator creates a logical conjunction
OrThis operator creates a logical disjunction

Comparison functions

Comparison functions are used to compare between different expressions and values, returning true or false accordingly.

EqualsThis operation checks if values are equal
Greater thanThis operator checks if first value is greater than the second value
Greater or equals toThis operator checks if first value is greater than or equal to the second value
Less than or equals to This operator checks if first value is smaller than or equal to the second value
Not equals toThis operator checks if given expression not equal to give value

How-to video

Learn how to transform personalization values using personalization helper functions and understand different use cases for helper functions.

On this page