Product ID is ingested into the system as follows:
Product ID: 1234|09876|23792
Then, although the values are separated by a pipe character, the system identifies it as a single string, which is incorrect. Moreover, storing it as a string restricts proper filtering in the downstream modules. To avoid this, store it as a list or array of strings. However, since the value is not initially in list or array format, the system converts the entire data into a single value and stores it as ProdID(List String) = ["1234|09876|23792"]. To correct this, use the following directives in your transformer:
Directives for Data Transformation
Code
| Directive | Description | ||
|---|---|---|---|
| `ProdID(List String) = [“1234 | 09876 | 23792”]` | Converts the String value to list of Strings |
find-and-replace products s/|/”,”/g | Finds and replaces all occurrences of the pipe character (“ | ”) with commas (”,“) | |
find-and-replace products s/^/[“/g | Adds a double quotation mark (”) at the beginning of each value | ||
find-and-replace products s/$/”]/g | Adds a double quotation mark (”) at the end of each value | ||
parse-as-cdt :product ID APPEND LIST | Reads the “Product ID” field as a list of strings
|
Product ID: ["1234", "09876", "23792"]. This facilitates straightforward filtering of the values in downstream systems such as Audiences.