Updating an XDM Custom Field Group Array with a Data Element in Update Variable Action (Variable Editor) | Community
Skip to main content
Level 4
January 27, 2025
Question

Updating an XDM Custom Field Group Array with a Data Element in Update Variable Action (Variable Editor)

  • January 27, 2025
  • 2 replies
  • 1246 views

Hi,

I need some help on how to update a custom field group I created, which expects an array of strings. I don't see any examples, so I hope it is straight forward. The path is "_drh.menuArr" and I want to be able to populate it with anywhere from 1 - 6 values via a data element. Is populating it as easy as having the data element just return the entire array to the field group or do I have to loop through the values and return each value individually? If I have to return each value individually, how does this work? I'm not sure if I have to specify the index for each value or will the schema auto index the returned values?  For example, Let's say my data element wants to return these values: 

 

// Example of data element named "arrayOfMenuItems" which wants to populate "_drh.menuArr"
var dataElementMenuItems  = ["up", "down", "left"];

How would I populate the "_drh.menuArr" field group via the data element?

 

Thanks!

2 replies

TylerKrause
Adobe Champion
Adobe Champion
January 28, 2025

Can you expand a little bit more on how you're hoping to get it from the data element to that dataset? 

Level 4
January 28, 2025

Hi,

In the Data Collection rule where I'm doing an update variable action, within the variable editor where I can specify a data element for the value.

TylerKrause
Adobe Champion
Adobe Champion
January 28, 2025

@harveer_singhgi1's response will get you exactly what you're looking for! You can use that field in the Audiences view to build audiences, count attiriutes and any other personalization you want to do.

You can also view and analyze those metrics more in depth in CJA. This should get you exactly what you're looking for!

Harveer_SinghGi1
Community Advisor
Community Advisor
January 28, 2025

Hi @michaeljo13 ,

I assume it is a XDM field that you created (and not a field group) which show data type as string[] next to it's name in the schema view.

If that is the case then it should be pretty straight forward as below,

 

//settings data element named "Menu Items"

var dataElementMenuItems  = ["up", "down", "left"];

return dataElementMenuItems ;

 

//xdm data element mapping

_drh.menuArr = %Menu Items%

Cheers!

Level 4
January 28, 2025

Hi Harveer,

You are correct. So, I just return the whole array. Do you know how CJA reports on the individual items passed? What I want is to have the instances of each item in a report. The values populating the array come from a multi-select combo box.

 

Thanks!

Harveer_SinghGi1
Community Advisor
Community Advisor
January 29, 2025

Hi @michaeljo13 ,

CJA treats String Arrays similar to how Adobe Analytics works with List Variables. The values passed in a String Array are reported as individual values. So for an example a single hit where you recorded _drh.menuArr field in XDM as ["up", "down", "left"] and let's says passed two metric fields also in the same hit; Metric 1 and Metric 2 will show as below when you run the CJA report for these fields,

_drh.menuArrMetric1Metric2
up11
down11
left11

All the values in String array will be shown as individual row items each taking full credit for the metrics recorded on that hit.

Cheers!