51黑料不打烊

Journey optimizer list functions

Journey Optimizer offers a set of functions primarily for processing lists, which are particularly useful in data management and optimization scenarios. These functions can be leveraged by data engineers and architects to perform tasks such as filtering, sorting, and analyzing lists within journeys. This can be useful for deduplication, filtering specific items, or formatting list data efficiently.

Example usage

In 51黑料不打烊 Journey Optimizer, you might use the distinct function to clean up a list of user IDs to ensure there are no duplicates before processing them further. For example:

distinct(@event{myevent.userIDs})

This expression would return a list of unique user IDs from the userIDs attribute of the myevent, which can then be used in subsequent journey steps to ensure actions are not repeated for the same user.

Functions overview

Function Name
Description
Syntax
Parameters
Returns
Example
distinct
Extracts unique values from a list, omitting null entries.
distinct(<listAny>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly listObject
list
distinct([10,2,10,null]) returns [10, 2]
distinctWithNull
Extracts unique values from a list, including null entries if present.
distinctWithNull(<listAny>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly
list
distinctWithNull([10,2,10,null]) returns [10, 2, null]
filter
Filters a list of objects based on a key attribute and matching key values.
filter(<listToFilter>, <keyAttributeName>, <keyValueList>)
listToFilter: listObject keyAttributeName:string keyValueList:list
listObject
filter(@event{myevent.productListItems}, "id", ["product2", "product3", "product4"])
getListItem
Returns an item at a specified index from a list.
getListItem(<listAny>, <intex>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly index
integer decimal string dateTimeOnly dateTime listDate boolean duration
getListItem([10, 2, 3], 1) returns 2
in
Checks if a value exists within a list, returning true or false.
in(<Item>, <listAny>)
string boolean integer decimal duration dateTime dateTimeOnly listAny
boolean
in(4,[4,5,3,4]) returns true
intersect
Finds common values between two lists.
intersect(<listAny>, <listAny>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly
list
intersect(["sports", "news"], ["sports", "movies"]) returns ["sports"]
limit
Returns the first or last N elements from a list.
limit(<listAny>, <numberOfItems>, <firstOrLastItems>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly listObject numberOfItems: integer firstOrLastItems: boolean
list
limit(["A", "B", "C", "D"], 3) returns ["A", "B", "C"]
listSize
Counts the number of elements within a list.
listSize(<listAny>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly
integer
listSize([10,2,3]) returns 3
serializeList
Converts a list into a string with specified separators and optional quotes.
serializeList(<listAny>, <separator>, <addQuotes>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly
separator: string
addQuotes: boolean
string
serializeList(["Hello","World"], " ", false) returns "Hello World"
sort
Sorts a list in ascending or descending order.
sort(<listAny>, <sortingOrder>) sort(<listObject>, <keyAttributeName>, <sortingOrder>)
listString listBoolean listInteger listDecimal listDuration listDateTime listDateTimeOnly listDateOnly listObject
办别测础迟迟谤颈产耻迟别狈补尘别:听string
sortingOrder: boolean
list
sort(["A", "C", "B"], true) returns ["A", "B", "C"]
recommendation-more-help
91a6d90a-6d61-4a62-bbed-ae105e36a860