Expand my Community achievements bar.

Mapping Nested Product Category Arrays Using Calculated Fields in AEP

Avatar

Level 3

Hi Everyone,

I have a set of product array data in a CSV file, as shown in the example below.

SKUQuantitycategoryIDcategoryName
ABC|DER1|4Category123;Category122;Category333|Category111;Category888Watch;Men;Apparel|Shirt;Women

Now, I want to map these field to ProductListItems array field in Adobe Analytics Experience Event Template. I am able to Map the SKU, and Quantity field using array_to_objects and explode functions. When I use this same functions for the categoryID, and CategoryName I am getting the below output,

Formula:

arrays_to_objects('SKU',explode(SKU,'\|'),'Quantity',explode(Quantity,'\|'), 'ProductCategories.CategoryName',explode(categoryName,'\|'),'ProductCategories.CategoryID',explode(categoryID,'\|'))

Output:
[{"Quantity":"1","SKU":"ABC","ProductCategories.CategoryName":"Watch;Men;Apparel","ProductCategories.CategoryID":"Category123;Category122;Category333"}]

 

Not able to use the array_to_objects function within the array_to_objects function.

The output I actually need is given below,

[{
"Quantity":"1",
"SKU":"ABC",
"ProductCategories":[
        {
             "CategoryName":"Watch",
             "CategoryID":"Category123"
        },
       {
             "CategoryName":"Men",
             "CategoryID":"Category122"
        },
       { 
            "CategoryName":"Apparel", 
             "CategoryID":"Category333"
       }
]
}]
 
What is the recommended method for accomplishing this with a calculated field? I’d appreciate any best practices.

Thanks in advance.!
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies