Hi - I'm new to "Calculated Fields" and am struggling. I have a data layer that contains nested arrays. I'm trying to reduce client-side processing on the user browser by moving some of the processing server-side.
I can send the data layer event object to the web SDK. When I come to map the data stream, I can define incoming source data by providing my JSON schema object for the data layer (which contains arrays), but then when I come to the next screen, if I want to get a specific key value pair from the objects within the array, and then convert this into a concatenated string to return as a single data point, how is this achieved?
I imagine some combination of "map_get_values" and a version of toString("_") (which I can't locate) to turn the array returned by the map function into a string.
For example:
input = [{"name": "name1"},{"name": "name2"},{"name": "name3"},{"name": "name4"}];
How could I use map to return a value like this - "name1_name2_name3_name4"
In standard JS, it'd just be something like: return input.map(function(key){return key.name}).toString("_");
^^ and I'd be able to then pass the output directly to a variable of my choice.
How can the same be achieved in calculated fields? Does it have to map to another object within the schema, and then that is mapped, or can you simply return the output and map it directly?
Thanks