Data Prep mapping functions

Last update: 2024-10-09
  • Created for:
  • Developer

Data Prep functions can be used to compute and calculate values based on what is entered in source fields.

Fields

A field name can be any legal identifier - an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign ($), or the underscore character (_). Variable names are also case sensitive.

If a field name does not follow this convention, the field name must be wrapped with ${}. So, for example, if the field name is “First Name” or “First.Name”, then the name must be wrapped like ${First Name} or ${First\.Name} respectively.

TIP

When interacting with hierarchies, if a child attribute has a period (.), you must use a backslash (\) to escape special characters. For more information, read the guide on escaping special characters.

If a field name is any of the following reserved keywords, it must be wrapped with ${}{}:

new, mod, or, break, var, lt, for, false, while, eq, gt, div, not, null, continue, else, and, ne, true, le, if, ge, return, _errors, do, function, empty, size

Additionally, reserved keywords also include any of the mapper functions listed on this page.

Data within sub-fields can be accessed by using the dot notation. For example, if there was a name object, to access the firstName field, use name.firstName.

List of functions

The following tables list all supported mapping functions, including sample expressions and their resulting outputs.

String functions

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
concat Concatenates the given strings.
  • STRING: The strings that will be concatenated.
concat(STRING_1, STRING_2) concat("Hi, ", “there”, “!”) "Hi, there!"
explode Splits the string based on a regex and returns an array of parts. Can optionally include regex to split the string. By default, the splitting resolves to “,”. The following delimiters need to be escaped with \: +, ?, ^, |, ., [, (, {, ), *, $, \ If you include multiple characters as the delimiter, the delimiter will be treated as a multi-character delimiter.
  • STRING: Required The string that needs to be split.
  • REGEX: Optional The regular expression that can be used to split the string.
explode(STRING, REGEX) explode(“Hi, there!”, " ") ["Hi,", "there"]
instr Returns the location/index of a substring.
  • INPUT: Required The string that is being searched.
  • SUBSTRING: Required The substring that is being searched for within the string.
  • START_POSITION: Optional The location of where to start looking in the string.
  • OCCURRENCE: Optional The nth occurrence to look for from the start position. By default, it is 1.
instr(INPUT, SUBSTRING, START_POSITION, OCCURRENCE) instr(“adobe.com”, “com”) 6
replacestr Replaces the search string if present in original string.
  • INPUT: Required The input string.
  • TO_FIND: Required The string to look up within the input.
  • TO_REPLACE: Required The string that will replace the value within “TO_FIND”.
replacestr(INPUT, TO_FIND, TO_REPLACE) replacestr(“This is a string re test”, “re”, “replace”) “This is a string replace test”
substr Returns a substring of a given length.
  • INPUT: Required The input string.
  • START_INDEX: Required The index of the input string where the substring starts.
  • LENGTH: Required The length of the substring.
substr(INPUT, START_INDEX, LENGTH) substr(“This is a substring test”, 7, 8) " a subst"
lower /
lcase
Converts a string to lowercase.
  • INPUT: Required The string that will be converted to lowercase.
lower(INPUT) lower(“HeLLo”)
lcase(“HeLLo”)
“hello”
upper /
ucase
Converts a string to uppercase.
  • INPUT: Required The string that will be converted to uppercase.
upper(INPUT) upper(“HeLLo”)
ucase(“HeLLo”)
“HELLO”
split Splits an input string on a separator. The following separator needs to be escaped with \: \. If you include multiple delimiters, the string will split on any of the delimiters present in the string. Note: This function only returns non-null indexes from the string, regardless of the presence of the separator. If all indexes, including nulls, are required in the resulting array, use the “explode” function instead.
  • INPUT: Required The input string that is going to be split.
  • SEPARATOR: Required The string that is used to split the input.
split(INPUT, SEPARATOR) split(“Hello world”, " ") ["Hello", "world"]
join Joins a list of objects using the separator.
  • SEPARATOR: Required The string that will be used to join the objects.
  • OBJECTS: Required An array of strings that will be joined.
join(SEPARATOR, [OBJECTS]) join(" ", to_array(true, "Hello", "world")) “Hello world”
lpad Pads the left side of a string with the other given string.
  • INPUT: Required The string that is going to be padded out. This string can be null.
  • COUNT: Required The size of the string to be padded out.
  • PADDING: Required The string to pad the input with. If null or empty, it will be treated as a single space.
lpad(INPUT, COUNT, PADDING) lpad(“bat”, 8, “yz”) “yzyzybat”
rpad Pads the right side of a string with the other given string.
  • INPUT: Required The string that is going to be padded out. This string can be null.
  • COUNT: Required The size of the string to be padded out.
  • PADDING: Required The string to pad the input with. If null or empty, it will be treated as a single space.
rpad(INPUT, COUNT, PADDING) rpad(“bat”, 8, “yz”) “batyzyzy”
left Gets the first “n” characters of the given string.
  • STRING: Required The string you are getting the first “n” characters for.
  • COUNT: RequiredThe “n” characters you want to get from the string.
left(STRING, COUNT) left(“abcde”, 2) “ab”
right Gets the last “n” characters of the given string.
  • STRING: Required The string you are getting the last “n” characters for.
  • COUNT: RequiredThe “n” characters you want to get from the string.
right(STRING, COUNT) right(“abcde”, 2) “de”
ltrim Removes the whitespace from the beginning of the string.
  • STRING: Required The string you want to remove the whitespace from.
ltrim(STRING) ltrim(" hello") “hello”
rtrim Removes the whitespace from the end of the string.
  • STRING: Required The string you want to remove the whitespace from.
rtrim(STRING) rtrim("hello ") “hello”
trim Removes the whitespace from the beginning and the end of the string.
  • STRING: Required The string you want to remove the whitespace from.
trim(STRING) trim(" hello ") “hello”
equals Compares two strings to confirm if they are equal. This function is case sensitive.
  • STRING1: Required The first string you want to compare.
  • STRING2: Required The second string you want to compare.
STRING1.​equals(​STRING2) “string1”.​equals​(“STRING1”) false
equalsIgnoreCase Compares two strings to confirm if they are equal. This function is not case sensitive.
  • STRING1: Required The first string you want to compare.
  • STRING2: Required The second string you want to compare.
STRING1.​equalsIgnoreCase​(STRING2) “string1”.​equalsIgnoreCase​("STRING1) true

Regular expression functions

Function Description Parameters Syntax Expression Sample output
extract_regex Extracts groups from the input string, based on a regular expression.
  • STRING: Required The string that you are extracting the groups from.
  • REGEX: Required The regular expression that you want the group to match.
extract_regex(STRING, REGEX) extract_regex​("E259,E259B_009,1_1"​, “([,]+),[,]*,([^,]+)”) [“E259,E259B_009,1_1”, “E259”, “1_1”]
matches_regex Checks to see if the string matches against the inputted regular expression.
  • STRING: Required The string that you are checking matches the regular expression.
  • REGEX: Required The regular expression that you are comparing against.
matches_regex(STRING, REGEX) matches_regex(“E259,E259B_009,1_1”, “([,]+),[,]*,([^,]+)”) true

Hashing functions

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
sha1 Takes an input and produces a hash value using Secure Hash Algorithm 1 (SHA-1).
  • INPUT: Required The plain text to be hashed.
  • CHARSET: Optional The name of the character set. Possible values include UTF-8, UTF-16, ISO-8859-1, and US-ASCII.
sha1(INPUT, CHARSET) sha1(“my text”, “UTF-8”) c3599c11e47719df18a24​48690840c5dfcce3c80
sha256 Takes an input and produces a hash value using Secure Hash Algorithm 256 (SHA-256).
  • INPUT: Required The plain text to be hashed.
  • CHARSET: Optional The name of the character set. Possible values include UTF-8, UTF-16, ISO-8859-1, and US-ASCII.
sha256(INPUT, CHARSET) sha256(“my text”, “UTF-8”) 7330d2b39ca35eaf4cb95fc846c21​ee6a39af698154a83a586ee270a0d372104
sha512 Takes an input and produces a hash value using Secure Hash Algorithm 512 (SHA-512).
  • INPUT: Required The plain text to be hashed.
  • CHARSET: Optional The name of the character set. Possible values include UTF-8, UTF-16, ISO-8859-1, and US-ASCII.
sha512(INPUT, CHARSET) sha512(“my text”, “UTF-8”) a3d7e45a0d9be5fd4e4b9a3b8c9c2163c21ef​708bf11b4232bb21d2a8704ada2cdcd7b367dd0788a89​a5c908cfe377aceb1072a7b386b7d4fd2ff68a8fd24d16
md5 Takes an input and produces a hash value using MD5.
  • INPUT: Required The plain text to be hashed.
  • CHARSET: Optional The name of the character set. Possible values include UTF-8, UTF-16, ISO-8859-1, and US-ASCII.
md5(INPUT, CHARSET) md5(“my text”, “UTF-8”) d3b96ce8c9fb4​e9bd0198d03ba6852c7
crc32 Takes an input uses a cyclic redundancy check (CRC) algorithm to produce a 32-bit cyclic code.
  • INPUT: Required The plain text to be hashed.
  • CHARSET: Optional The name of the character set. Possible values include UTF-8, UTF-16, ISO-8859-1, and US-ASCII.
crc32(INPUT, CHARSET) crc32(“my text”, “UTF-8”) 8df92e80

URL functions

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
get_url_protocol Returns the protocol from the given URL. If the input is invalid, it returns null.
  • URL: Required The URL from which the protocol needs to be extracted.
get_url_protocol​(URL) get_url_protocol(“https://platform​.adobe.com/home”) https
get_url_host Returns the host of the given URL. If the input is invalid, it returns null.
  • URL: Required The URL from which the host needs to be extracted.
get_url_host​(URL) get_url_host​(“https://platform​.adobe.com/home”) platform.adobe.com
get_url_port Returns the port of the given URL. If the input is invalid, it returns null.
  • URL: Required The URL from which the port needs to be extracted.
get_url_port(URL) get_url_port​(“sftp://example.com//home/​joe/employee.csv”) 22
get_url_path Returns the path of the given URL. By default, the full path is returned.
  • URL: Required The URL from which the path needs to be extracted.
  • FULL_PATH: Optional A boolean value that determines if the full path is returned. If set to false, only the end of the path is returned.
get_url_path​(URL, FULL_PATH) get_url_path​(“sftp://example.com//​home/joe/employee.csv”) “//home/joe/​employee.csv”
get_url_query_str Returns the query string of a given URL as a map of query string name and query string value.
  • URL: Required The URL that you are trying to get the query string from.
  • ANCHOR: Required Determines what will be done with the anchor in the query string. Can be one of three values: “retain”, “remove”, or “append”.

    If the value is “retain”, the anchor will be attached to the returned value.
    If the value is “remove”, the anchor will be removed from the returned value.
    If the value is “append”, the anchor will be returned as a separate value.
get_url_query_str​(URL, ANCHOR) get_url_query_str​(“foo://example.com:8042​/over/there?name=​ferret#nose”, “retain”)
get_url_query_str​(“foo://example.com:8042​/over/there?name=​ferret#nose”, “remove”)
get_url_query_str​(“foo://example.com​:8042/over/there​?name=ferret#nose”, “append”)
{"name": "ferret#nose"}
{"name": "ferret"}
{"name": "ferret", "_anchor_": "nose"}
get_url_encoded This function takes a URL as input and replaces or encodes the special characters with ASCII characters. For more information on special characters, please read the list of special characters in the appendix of this document.
  • URL: Required The input URL with special characters that you want to replace or encode with ASCII characters.
get_url_encoded(URL) get_url_encoded(“https://example.com/partneralliance_asia-pacific_2022”) https%3A%2F%2Fexample.com%2Fpartneralliance_asia-pacific_2022
get_url_decoded This function takes a URL as input and decodes the ASCII characters into special characters. For more information on special characters, please read the list of special characters in the appendix of this document.
  • URL: Required The input URL with ASCII characters that you want to decode into special characters.
get_url_decoded(URL) get_url_decoded(“https%3A%2F%2Fexample.com%2Fpartneralliance_asia-pacific_2022”) https://example.com/partneralliance_asia-pacific_2022

Date and time functions

NOTE

Please scroll left/right to view the full contents of the table. More information about the date function can be found in the dates section of the data format handling guide.

Function Description Parameters Syntax Expression Sample output
now Retrieves the current time. now() now() 2021-10-26T10:10:24Z
timestamp Retrieves the current Unix time. timestamp() timestamp() 1571850624571
format Formats the input date according to a specified format.
  • DATE: Required The input date, as a ZonedDateTime object, that you want to format.
  • FORMAT: Required The format that you want the date to be changed to.
format(DATE, FORMAT) format(2019-10-23T11:24:00+00:00, “yyyy-MM-dd HH:mm:ss”) 2019-10-23 11:24:35
dformat Converts a timestamp to a date string according to a specified format.
  • TIMESTAMP: Required The timestamp you want to format. This is written in milliseconds.
  • FORMAT: Required The format that you want the timestamp to become.
dformat(TIMESTAMP, FORMAT) dformat(1571829875000, “yyyy-MM-dd'T'HH:mm:ss.SSSX”) 2019-10-23T11:24:35.000Z
date Converts a date string into a ZonedDateTime object (ISO 8601 format).
  • DATE: Required The string that represents the date.
  • FORMAT: Required The string representing the format of the source date.Note: This does not represent the format you want to convert the date string into.
  • DEFAULT_DATE: Required The default date returned, if the date provided is null.
date(DATE, FORMAT, DEFAULT_DATE) date(“2019-10-23 11:24”, “yyyy-MM-dd HH:mm”, now()) 2019-10-23T11:24:00Z
date Converts a date string into a ZonedDateTime object (ISO 8601 format).
  • DATE: Required The string that represents the date.
  • FORMAT: Required The string representing the format of the source date.Note: This does not represent the format you want to convert the date string into.
date(DATE, FORMAT) date(“2019-10-23 11:24”, “yyyy-MM-dd HH:mm”) 2019-10-23T11:24:00Z
date Converts a date string into a ZonedDateTime object (ISO 8601 format).
  • DATE: Required The string that represents the date.
date(DATE) date(“2019-10-23 11:24”) “2019-10-23T11:24:00Z”
date_part Retrieves the parts of the date. The following component values are supported:

“year”
“yyyy”
“yy”

“quarter”
“qq”
“q”

“month”
“mm”
“m”

“dayofyear”
“dy”
“y”

“day”
“dd”
“d”

“week”
“ww”
“w”

“weekday”
“dw”
“w”

“hour”
“hh”
“hh24”
“hh12”

“minute”
“mi”
“n”

“second”
“ss”
“s”

“millisecond”
“SSS”
  • COMPONENT: Required A string representing the part of the date.
  • DATE: Required The date, in a standard format.
date_part​(COMPONENT, DATE) date_part(“MM”, date(“2019-10-17 11:55:12”)) 10
set_date_part Replaces a component in a given date. The following components are accepted:

“year”
“yyyy”
“yy”

“month”
“mm”
“m”

“day”
“dd”
“d”

“hour”
“hh”

“minute”
“mi”
“n”

“second”
“ss”
“s”
  • COMPONENT: Required A string representing the part of the date.
  • VALUE: Required The value to set for the component for a given date.
  • DATE: Required The date, in a standard format.
set_date_part​(COMPONENT, VALUE, DATE) set_date_part(“m”, 4, date(“2016-11-09T11:44:44.797”) “2016-04-09T11:44:44Z”
make_date_time Creates a date from parts. This function can also be induced using make_timestamp.
  • YEAR: Required The year, written in four digits.
  • MONTH: Required The month. The allowed values are 1 to 12.
  • DAY: Required The day. The allowed values are 1 to 31.
  • HOUR: Required The hour. The allowed values are 0 to 23.
  • MINUTE: Required The minute. The allowed values are 0 to 59.
  • NANOSECOND: Required The nanosecond values. The allowed values are 0 to 999999999.
  • TIMEZONE: Required The timezone for the date time.
make_date_time​(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, NANOSECOND, TIMEZONE) make_date_time​(2019, 10, 17, 11, 55, 12, 999, “America/Los_Angeles”) 2019-10-17T11:55:12Z
zone_date_to_utc Converts a date in any timezone to a date in UTC.
  • DATE: Required The date that you are trying to convert.
zone_date_to_utc​(DATE) zone_date_to_utc​(2019-10-17T11:55:​12 PST 2019-10-17T19:55:12Z
zone_date_to_zone Converts a date from one timezone to another timezone.
  • DATE: Required The date that you are trying to convert.
  • ZONE: Required The timezone that you are trying to convert the date to.
zone_date_to_zone​(DATE, ZONE) zone_date_to_zone(now(), "Europe/Paris") 2021-10-26T15:43:59Z

Hierarchies - Objects

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
is_empty Checks whether or not an object is empty.
  • INPUT: Required The object that you’re trying to check is empty.
is_empty(INPUT) is_empty([1, null, 2, 3]) false
arrays_to_object Creates a list of objects.
  • INPUT: Required A grouping of key and array pairs.
arrays_to_object(INPUT) arrays_to_objects('sku', explode("id1|id2", '\\|'), 'price', [22.5,14.35]) [{ "sku": "id1", "price": 22.5 }, { "sku": "id2", "price": 14.35 }]
to_object Creates an object based on the flat key/value pairs given.
  • INPUT: Required A flat list of key/value pairs.
to_object(INPUT) to_object​(“firstName”, “John”, “lastName”, “Doe”) {"firstName": "John", "lastName": "Doe"}
str_to_object Creates an object from the input string.
  • STRING: Required The string that is being parsed to create an object.
  • VALUE_DELIMITER: Optional The delimiter that separates a field from the value. The default delimiter is :.
  • FIELD_DELIMITER: Optional The delimiter that separates field value pairs. The default delimiter is ,.
str_to_object​(STRING, VALUE_DELIMITER, FIELD_DELIMITER) Note: You can use the get() function along with str_to_object() to retrieve values for the keys in the string.
  • Example #1: str_to_object(“firstName - John ; lastName - ; - 123 345 7890”, “-”, “;”)
  • Example #2: str_to_object(“firstName - John ; lastName - ; phone - 123 456 7890”, “-”, “;”).get(“firstName”)
  • Example #1:{"firstName": "John", "lastName": "Doe", "phone": "123 456 7890"}
  • Example #2: “John”
contains_key Checks if the object exists within the source data. Note: This function replaces the deprecated is_set() function.
  • INPUT: Required The path to be checked if it exists within the source data.
contains_key(INPUT) contains_key(“evars.evar.field1”) true
nullify Sets the value of the attribute to null. This should be used when you do not want to copy the field to the target schema. nullify() nullify() null
get_keys Parses the key/value pairs and returns all the keys.
  • OBJECT: Required The object where the keys will be extracted from.
get_keys(OBJECT) get_keys({“book1”: “Pride and Prejudice”, “book2”: “1984”}) ["book1", "book2"]
get_values Parses the key/value pairs and returns the value of the string, based on the given key.
  • STRING: Required The string that you want to parse.
  • KEY: Required The key for which the value has to be extracted.
  • VALUE_DELIMITER: Required The delimiter that separates the field and the value. If either a null or an empty string are provided, this value is :.
  • FIELD_DELIMITER: Optional The delimiter that separates field and value pairs. If either a null or an empty string are provided, this value is ,.
get_values(STRING, KEY, VALUE_DELIMITER, FIELD_DELIMITER) get_values(“firstName - John , lastName - Cena , phone - 555 420 8692”, “firstName”, “-”, “,”) John
map_get_values Takes a map and a key input. If the input is a single key, then the function returns the value associated with that key. If the input is a string array, then the function returns all values corresponding to the keys provided. If the incoming map has duplicate keys, the return value must de-duplicate the keys and return unique values.
  • MAP: Required The input map data.
  • KEY: Required The key can be a single string or a string array. If any other primitive type (data / number) is provided, then it is treated as a string.
get_values(MAP, KEY) Please see the appendix for a code sample.
map_has_keys If one or more input keys are provided, then the function returns true. If a string array is provided as input, then the function returns true on the first key that is found.
  • MAP: Required The input map data
  • KEY: Required The key can be a single string or a string array. If any other primitive type (data / number) is provided, then it is treated as a string.
map_has_keys(MAP, KEY) Please see the appendix for a code sample.
add_to_map Accepts at least two inputs. Any number of maps can be provided as inputs. Data Prep returns a single map that has all key-value pairs from all the inputs. If one or more keys are repeated (in the same map or across maps), Data Prep de-duplicates the keys so that the first key-value pair persists in the order that they were passed in the input. MAP: Required The input map data. add_to_map(MAP 1, MAP 2, MAP 3, …) Please see the appendix for a code sample.
object_to_map (Syntax 1) Use this function to create Map data types.
  • KEY: Required Keys must be a string. If any other primitive values such as integers or dates are provided, then they are auto-converted to strings and are treated as strings.
  • ANY_TYPE: Required Refers to any supported XDM data type except Maps.
object_to_map(KEY, ANY_TYPE, KEY, ANY_TYPE, … ) Please see the appendix for a code sample.
object_to_map (Syntax 2) Use this function to create Map data types.
  • OBJECT: Required You can provide an incoming object or object array and point to an attribute inside the object as key.
object_to_map(OBJECT) Please see the appendix for a code sample.
object_to_map (Syntax 3) Use this function to create Map data types.
  • OBJECT: Required You can provide an incoming object or object array and point to an attribute inside the object as key.
object_to_map(OBJECT_ARRAY, ATTRIBUTE_IN_OBJECT_TO_BE_USED_AS_A_KEY) Please see the appendix for a code sample.

For information on the object copy feature, see the section below.

Hierarchies - Arrays

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
coalesce Returns the first non-null object in a given array.
  • INPUT: Required The array you want to find the first non-null object of.
coalesce(INPUT) coalesce(null, null, null, “first”, null, “second”) “first”
first Retrieves the first element of the given array.
  • INPUT: Required The array you want to find the first element of.
first(INPUT) first(“1”, “2”, “3”) “1”
last Retrieves the last element of the given array.
  • INPUT: Required The array you want to find the last element of.
last(INPUT) last(“1”, “2”, “3”) “3”
add_to_array Adds elements to the end of the array.
  • ARRAY: Required The array that you are adding elements to.
  • VALUES: The elements that you want to append to the array.
add_to_array​(ARRAY, VALUES) add_to_array​([‘a’, ‘b’], ‘c’, ‘d’) [‘a’, ‘b’, ‘c’, ‘d’]
join_arrays Combines the arrays with each other.
  • ARRAY: Required The array that you are adding elements to.
  • VALUES: The array(s) you want to append to the parent array.
join_arrays​(ARRAY, VALUES) join_arrays​([‘a’, ‘b’], [‘c’], [‘d’, ‘e’]) [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
to_array Takes a list of inputs and converts it to an array.
  • INCLUDE_NULLS: Required A boolean value to indicate whether or not to include nulls in the response array.
  • VALUES: Required The elements that are to be converted to an array.
to_array​(INCLUDE_NULLS, VALUES) to_array(false, 1, null, 2, 3) [1, 2, 3]
size_of Returns the size of the input.
  • INPUT: Required The object that you’re trying to find the size of.
size_of(INPUT) size_of([1, 2, 3, 4]) 4
upsert_array_append This function is used to append all elements in the entire input array to the end of the array in Profile. This function is only applicable during updates. If used in the context of inserts, this function returns the input as is.
  • ARRAY: Required The array to append the array in the Profile.
upsert_array_append(ARRAY) upsert_array_append([123, 456]) [123, 456]
upsert_array_replace This function is used to replace elements in an array. This function is only applicable during updates. If used in the context of inserts, this function returns the input as is.
  • ARRAY: Required The array to replace the array in the Profile.
upsert_array_replace(ARRAY) upsert_array_replace([123, 456], 1) [123, 456]
Destinations only array_to_string Joins the string representations of the elements in an array using the specified separator. If the array is multidimensional, it is flattened before being joined. Note: This function is used in destinations. Read the documentation for more information.
  • SEPARATOR: Required The separator used to join the elements in the array.
  • ARRAY: Required The array that be joined (after flattening).
array_to_string(SEPARATOR, ARRAY) array_to_string(";", ["Hello", "world"]) “Hello;world”
Destinations only filterArray* Filters the given array based on a predicate. Note: This function is used in destinations. Read the documentation for more information.
  • ARRAY: Required The array to be filtered
  • PREDICATE: Required The predicate to be applied on each element of the given array.
filterArray(ARRAY, PREDICATE) filterArray([5, -6, 0, 7], x -> x > 0) [5, 7]
Destinations only transformArray* Transforms the given array based on a predicate. Note: This function is used in destinations. Read the documentation for more information.
  • ARRAY: Required The array to be transformed.
  • PREDICATE: Required The predicate to be applied on each element of the given array.
transformArray(ARRAY, PREDICATE) transformArray([5, 6, 7], x -> x + 1) [6, 7, 8]
Destinations only flattenArray* Flattens the given (multidimensional) array to a unidimensional array. Note: This function is used in destinations. Read the documentation for more information.
  • ARRAY: Required The array to be flattened.
flattenArray(ARRAY) flattenArray([[[‘a’, ‘b’], [‘c’, ‘d’]], [[‘e’], [‘f’]]]) [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’]

Hierarchies - Map

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
array_to_map This function takes an object array and a key as input and returns a map of key’s field with the value as key and the array element as value.
  • INPUT: Required The object array you want to find the first non-null object of.
  • KEY: Required The key must be a field name in the object array and the object as value.
array_to_map(OBJECT[] INPUTS, KEY) Read the appendix for a code sample.
object_to_map This function takes an object as an argument and returns a map of key-value pairs.
  • INPUT: Required The object array you want to find the first non-null object of.
object_to_map(OBJECT_INPUT) "object_to_map(address) where input is " + “address: {line1 : “345 park ave”,line2: “bldg 2”,City : “san jose”,State : “CA”,type: “office”}” Returns a map with given field name and value pairs or null if input is null. For example: "{line1 : \"345 park ave\",line2: \"bldg 2\",City : \"san jose\",State : \"CA\",type: \"office\"}"
to_map This function takes a list of ke-value pairs and returns a map of key-value pairs. to_map(OBJECT_INPUT) “to_map(“firstName”, “John”, “lastName”, “Doe”)” Returns a map with given field name and value pairs or null if input is null. For example: "{\"firstName\" : \"John\", \"lastName\": \"Doe\"}"

Logical operators

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
decode Given a key and a list of key value pairs flattened as an array, the function returns the value if key is found or return a default value if present in the array.
  • KEY: Required The key to be matched.
  • OPTIONS: Required A flattened array of key/value pairs. Optionally, a default value can be put at the end.
decode(KEY, OPTIONS) decode(stateCode, “ca”, “California”, “pa”, “Pennsylvania”, “N/A”) If the stateCode given is “ca”, “California”.
If the stateCode given is “pa”, “Pennsylvania”.
If the stateCode doesn’t match the following, “N/A”.
iif Evaluates a given boolean expression and returns the specified value based on the result.
  • EXPRESSION: Required The boolean expression that is being evaluated.
  • TRUE_VALUE: Required The value that is returned if the expression evaluates to true.
  • FALSE_VALUE: Required The value that is returned if the expression evaluates to false.
iif(EXPRESSION, TRUE_VALUE, FALSE_VALUE) iif(“s”.equalsIgnoreCase(“S”), “True”, “False”) “True”

Aggregation

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
min Returns the minimum of the given arguments. Uses natural ordering.
  • OPTIONS: Required One or more objects that can be compared to each other.
min(OPTIONS) min(3, 1, 4) 1
max Returns the maximum of the given arguments. Uses natural ordering.
  • OPTIONS: Required One or more objects that can be compared to each other.
max(OPTIONS) max(3, 1, 4) 4

Type conversions

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
to_bigint Converts a string to a BigInteger.
  • STRING: Required The string that is to be converted to a BigInteger.
to_bigint(STRING) to_bigint​(“1000000.34”) 1000000.34
to_decimal Converts a string to a Double.
  • STRING: Required The string that is to be converted to a Double.
to_decimal(STRING) to_decimal(“20.5”) 20.5
to_float Converts a string to a Float.
  • STRING: Required The string that is to be converted to a Float.
to_float(STRING) to_float(“12.3456”) 12.34566
to_integer Converts a string to an Integer.
  • STRING: Required The string that is to be converted to an Integer.
to_integer(STRING) to_integer(“12”) 12

JSON functions

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
json_to_object Deserialize JSON content from the given string.
  • STRING: Required The JSON string to be deserialized.
json_to_object​(STRING) json_to_object​({“info”:{“firstName”:“John”,“lastName”: “Doe”}}) An object representing the JSON.

Special operations

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
uuid /
guid
Generates a pseudo-random ID. uuid()
guid()
uuid()
guid()
7c0267d2-bb74-4e1a-9275-3bf4fccda5f4
c7016dc7-3163-43f7-afc7-2e1c9c206333
fpid_to_ecid This function takes an FPID string and converts it into an ECID to be used in Adobe Experience Platform and Adobe Experience Cloud applications.
  • STRING: Required The FPID string to be converted into ECID.
fpid_to_ecid(STRING) fpid_to_ecid("4ed70bee-b654-420a-a3fd-b58b6b65e991") "28880788470263023831040523038280731744"

User agent functions

Any of the user agent functions contained in the table below can return either of the following values:

  • Phone - A mobile device with a small screen (commonly < 7")
  • Mobile - A mobile device that is yet to be identified. This mobile device can be an eReader, a tablet, a phone, a watch, etc.

For more information on device field values, please read the list of device field values in the appendix of this document.

NOTE

Please scroll left/right to view the full contents of the table.

Function Description Parameters Syntax Expression Sample output
ua_os_name Extracts the operating system name from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_os_name​(USER_AGENT) ua_os_name​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) iOS
ua_os_version_major Extracts the operating system’s major version from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_os_version_major​(USER_AGENT) ua_os_version_major​s(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) iOS 5
ua_os_version Extracts the operating system’s version from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_os_version​(USER_AGENT) ua_os_version​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) 5.1.1
ua_os_name_version Extracts the operating system’s name and version from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_os_name_version​(USER_AGENT) ua_os_name_version​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) iOS 5.1.1
ua_agent_version Extracts the agent version from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_agent_version​(USER_AGENT) ua_agent_version​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) 5.1
ua_agent_version_major Extracts the agent name and major version from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_agent_version_major​(USER_AGENT) ua_agent_version_major​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) Safari 5
ua_agent_name Extracts the agent name from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_agent_name​(USER_AGENT) ua_agent_name​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) Safari
ua_device_class Extracts the device class from the user agent string.
  • USER_AGENT: Required The user agent string.
ua_device_class​(USER_AGENT) ua_device_class​(“Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3”) Phone

Analytics functions

NOTE

You may only use the following analytics functions for WebSDK and Adobe Analytics flows.

Function Description Parameters Syntax Expression Sample output
aa_get_event_id Extracts the event ID from an Analytics event string.
  • EVENT_STRING: Required The comma-separated Analytics event string.
  • EVENT_NAME: Required The event name to extract and ID from.
aa_get_event_id(EVENT_STRING, EVENT_NAME) aa_get_event_id(“event101=5:123456,scOpen”, “event101”) 123456
aa_get_event_value Extracts the event value from an Analytics event string. If the event value is not specified 1 is returned.
  • EVENT_STRING: Required The comma-separated Analytics event string.
  • EVENT_NAME: Required The event name to extract a value from.
aa_get_event_value(EVENT_STRING, EVENT_NAME) aa_get_event_value(“event101=5:123456,scOpen”, “event101”) 5
aa_get_product_categories Extracts the product category from an Analytics products string.
  • PRODUCTS_STRING: Required The Analytics products string.
aa_get_product_categories(PRODUCTS_STRING) aa_get_product_categories(“;Example product 1;1;3.50,Example category 2;Example product 2;1;5.99”) [null,“Example category 2”]
aa_get_product_names Extracts the product name from an Analytics products string.
  • PRODUCTS_STRING: Required The Analytics products string.
aa_get_product_names(PRODUCTS_STRING) aa_get_product_names(“;Example product 1;1;3.50,Example category 2;Example product 2;1;5.99”) [“Example product 1”,“Example product 2”]
aa_get_product_quantities Extracts the quantities from an Analytics products string.
  • PRODUCTS_STRING: Required The Analytics products string.
aa_get_product_quantities(PRODUCTS_STRING) aa_get_product_quantities(“;Example product 1;1;3.50,Example category 2;Example product 2”) [“1”, null]
aa_get_product_prices Extracts the price from an Analytics products string.
  • PRODUCTS_STRING: Required The Analytics products string.
aa_get_product_prices(PRODUCTS_STRING) aa_get_product_prices(“;Example product 1;1;3.50,Example category 2;Example product 2”) [“3.50”, null]
aa_get_product_event_values Extracts values for the named event from the products string as an array of strings.
  • PRODUCTS_STRING: Required The Analytics products string.
  • EVENT_NAME: Required The event name to extract values from.
aa_get_product_event_values(PRODUCTS_STRING, EVENT_NAME) aa_get_product_event_values(“;Example product 1;1;4.20;event1=2.3|event2=5:1,;Example product 2;1;4.20;event1=3|event2=2:2”, “event1”) [“2.3”, “3”]
aa_get_product_evars Extracts the evar values for the named event from the products string as an array of strings.
  • PRODUCTS_STRING: Required The Analytics products string.
  • EVAR_NAME: Required The eVar name to extract.
aa_get_product_evars(PRODUCTS_STRING, EVENT_NAME) aa_get_product_evars(“;Example product;1;6.69;;eVar1=Merchandising value”, “eVar1”) [“Merchandising value”]

Object copy

TIP

The object copy feature is automatically applied when an object in the source is mapped to an object in the XDM. No additional action needed from users.

You can use the object copy feature to automatically copy attributes of an object without making changes to the mapping. For example, if your source data has a structure of:

address{
        line1: 4191 Ridgebrook Way,
        city: San Jose,
        state: California
        }

and an XDM structure of:

addr{
    addrLine1: 4191 Ridgebrook Way,
    city: San Jose,
    state: California
    }

Then the mapping becomes:

address -> addr
address.line1 -> addr.addrLine1

In the example above, the city and state attributes are also ingested automatically at runtime because the address object is mapped to addr. If you were to create a line2 attribute in the XDM structure and your input data also contains a line2 in the address object, then it will also be automatically ingested without any need to manually alter the mapping.

To ensure that the automatic mapping works, the following prerequisites must be met:

  • Parent-level objects should be mapped;
  • New attributes must have been created in the XDM schema;
  • New attributes should have matching names in the source schema and the XDM schema.

If any of the prerequisites are not met, then you must manually map the source schema to the XDM schema using data prep.

Appendix

The following provides additional information on using Data Prep mapping functions

Special characters

The table below outlines a list of reserved characters and their corresponding encoded characters.

Reserved character Encoded character
space %20
! %21
" %22
# %23
$ %24
% %25
& %26
%27
( %28
) %29
* %2A
+ %2B
, %2C
/ %2F
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
@ %40
[ %5B
| %5C
] %5D
^ %5E
` %60
~ %7E

Device field values

The table below outlines a list of device field values and their corresponding descriptions.

Device Description
Desktop A Desktop or a Laptop type of device.
Anonymized An anonymous device. In some cases, these are useragents that have been altered by an anonymization software.
Unknown An unknown device. These are usually useragents that contain no information about the device.
Mobile A mobile device that is yet to be identified. This mobile device can be an eReader, a tablet, a phone, a watch, etc.
Tablet A mobile device with a large screen (commonly > 7").
Phone A mobile device with a small screen (commonly < 7").
Watch A mobile device with a tiny screen (commonly < 2"). These devices normally operate as an additional screen for a phone/tablet type of device.
Augmented Reality A mobile device with AR capabilities.
Virtual Reality A mobile device with VR capabilities.
eReader A device similar to a tablet, but usually with an eInk screen.
Set-top box A connected device that allows interaction through a TV-sized screen.
TV A device similar to the Set-top box, but is built into the TV.
Home Appliance A (usually large) home appliance, like a refrigerator.
Game Console A fixed gaming system like a Playstation or an XBox.
Handheld Game Console A mobile gaming system like a Nintendo Switch.
Voice A voice-driven device like an Amazon Alexa or a Google Home.
Car A vehicle-based browser.
Robot Robots that visit a website.
Robot Mobile Robots that visit a website but indicates that they want to be seen as a Mobile visitor.
Robot Imitator Robots that visit a website, pretending that are robots like Google, but they are not. Note: In most cases, Robot Imitators are indeed robots.
Cloud A cloud-based application. These are neither robots nor hackers, but are applications that need to connect. This includes Mastodon servers.
Hacker This device value is used in case scripting is detected in the useragent string.

Code samples

map_get_values

 Select to view example
 example = "map_get_values(book_details,\"author\") where input is : {\n" +
        "    \"book_details\":\n" +
        "    {\n" +
        "        \"author\": \"George R. R. Martin\",\n" +
        "        \"price\": 17.99,\n" +
        "        \"ISBN\": \"ISBN-978-0553801477\"\n" +
        "    }\n" +
        "}",
      result = "{\"author\": \"George R. R. Martin\"}"

map_has_keys

 Select to view example
 example = "map_has_keys(book_details,\"author\")where input is : {\n" +
        "    \"book_details\":\n" +
        "    {\n" +
        "        \"author\": \"George R. R. Martin\",\n" +
        "        \"price\": 17.99,\n" +
        "        \"ISBN\": \"ISBN-978-0553801477\"\n" +
        "    }\n" +
        "}",
      result = "true"

add_to_map

 Select to view example
example = "add_to_map(book_details, book_details2) where input is {\n" +
        "    \"book_details\":\n" +
        "    {\n" +
        "        \"author\": \"George R. R. Martin\",\n" +
        "        \"price\": 17.99,\n" +
        "        \"ISBN\": \"ISBN-978-0553801477\"\n" +
        "    }\n" +
        "}" +
        "{\n" +
        "    \"book_details2\":\n" +
        "    {\n" +
        "        \"author\": \"Neil Gaiman\",\n" +
        "        \"price\": 17.99,\n" +
        "        \"ISBN\": \"ISBN-0-380-97365-0\"\n" +
        "        \"publisher\": \"William Morrow\"\n" +
        "    }\n" +
        "}",
      result = "{\n" +
        "    \"book_details\":\n" +
        "    {\n" +
        "        \"author\": \"George R. R. Martin\",\n" +
        "        \"price\": 17.99,\n" +
        "        \"ISBN\": \"ISBN-978-0553801477\"\n" +
        "        \"publisher\": \"William Morrow\"\n" +
        "    }\n" +
        "}",
      returns = "A new map with all elements from map and addends"

object_to_map

Syntax 1

 Select to view example
example = "object_to_map(\"firstName\", \"John\", \"lastName\", \"Doe\")",
result = "{\"firstName\" : \"John\", \"lastName\": \"Doe\"}"

Syntax 2

 Select to view example
example = "object_to_map(address) where input is " +
  "address: {line1 : \"345 park ave\",line2: \"bldg 2\",City : \"san jose\",State : \"CA\",type: \"office\"}",
result = "{line1 : \"345 park ave\",line2: \"bldg 2\",City : \"san jose\",State : \"CA\",type: \"office\"}"

Syntax 3

 Select to view example
example = "object_to_map(addresses,type)" +
        "\n" +
        "[\n" +
        "    {\n" +
        "        \"line1\": \"345 park ave\",\n" +
        "        \"line2\": \"bldg 2\",\n" +
        "        \"City\": \"san jose\",\n" +
        "        \"State\": \"CA\",\n" +
        "        \"type\": \"home\"\n" +
        "    },\n" +
        "    {\n" +
        "        \"line1\": \"345 park ave\",\n" +
        "        \"line2\": \"bldg 2\",\n" +
        "        \"City \": \"san jose\",\n" +
        "        \"State\": \"CA\",\n" +
        "        \"type\": \"work\"\n" +
        "    },\n" +
        "    {\n" +
        "        \"line1\": \"345 park ave\",\n" +
        "        \"line2\": \"bldg 2\",\n" +
        "        \"City \": \"san jose\",\n" +
        "        \"State\": \"CA\",\n" +
        "        \"type\": \"office\"\n" +
        "    }\n" +
        "]" ,
result = "{\n" +
        "    \"home\":\n" +
        "    {\n" +
        "        \"line1\": \"345 park ave\",\n" +
        "        \"line2\": \"bldg 2\",\n" +
        "        \"City\": \"san jose\",\n" +
        "        \"State\": \"CA\",\n" +
        "        \"type\": \"home\"\n" +
        "    },\n" +
        "    \"work\":\n" +
        "    {\n" +
        "        \"line1\": \"345 park ave\",\n" +
        "        \"line2\": \"bldg 2\",\n" +
        "        \"City \": \"san jose\",\n" +
        "        \"State\": \"CA\",\n" +
        "        \"type\": \"work\"\n" +
        "    },\n" +
        "    \"office\":\n" +
        "    {\n" +
        "        \"line1\": \"345 park ave\",\n" +
        "        \"line2\": \"bldg 2\",\n" +
        "        \"City \": \"san jose\",\n" +
        "        \"State\": \"CA\",\n" +
        "        \"type\": \"office\"\n" +
        "    }\n" +
        "}"

array_to_map

 Select to view example
example = "array_to_map(addresses, \"type\") where addresses is\n" +
  "\n" +
  "[\n" +
  "    {\n" +
  "        \"line1\": \"345 park ave\",\n" +
  "        \"line2\": \"bldg 2\",\n" +
  "        \"City\": \"san jose\",\n" +
  "        \"State\": \"CA\",\n" +
  "        \"type\": \"home\"\n" +
  "    },\n" +
  "    {\n" +
  "        \"line1\": \"345 park ave\",\n" +
  "        \"line2\": \"bldg 2\",\n" +
  "        \"City \": \"san jose\",\n" +
  "        \"State\": \"CA\",\n" +
  "        \"type\": \"work\"\n" +
  "    },\n" +
  "    {\n" +
  "        \"line1\": \"345 park ave\",\n" +
  "        \"line2\": \"bldg 2\",\n" +
  "        \"City \": \"san jose\",\n" +
  "        \"State\": \"CA\",\n" +
  "        \"type\": \"office\"\n" +
  "    }\n" +
  "]" ,
result = "{\n" +
  "    \"home\":\n" +
  "    {\n" +
  "        \"line1\": \"345 park ave\",\n" +
  "        \"line2\": \"bldg 2\",\n" +
  "        \"City\": \"san jose\",\n" +
  "        \"State\": \"CA\",\n" +
  "        \"type\": \"home\"\n" +
  "    },\n" +
  "    \"work\":\n" +
  "    {\n" +
  "        \"line1\": \"345 park ave\",\n" +
  "        \"line2\": \"bldg 2\",\n" +
  "        \"City \": \"san jose\",\n" +
  "        \"State\": \"CA\",\n" +
  "        \"type\": \"work\"\n" +
  "    },\n" +
  "    \"office\":\n" +
  "    {\n" +
  "        \"line1\": \"345 park ave\",\n" +
  "        \"line2\": \"bldg 2\",\n" +
  "        \"City \": \"san jose\",\n" +
  "        \"State\": \"CA\",\n" +
  "        \"type\": \"office\"\n" +
  "    }\n" +
  "}",
returns = "Returns a map with given field name and value pairs or null if input is null"

On this page