I have Arrays/Collections as per below. There could be 1 to many of these “Variants”
I have created a JSON data structure as per below:
Instead of creating each of these, 1 by one as I have done in the image above, is there a cleaner method given I dont know how many items there will be ?
You can iterate the variantOptions array, and then aggregate to array.
Every result (item/record) from a iterator module will output a bundle. To “combine” them into a single structure, you’ll need to use an aggregator of some sort.
Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and has applies to many use-cases.
Read this
The Array Aggregator module allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.
Here is an example of using the “Target structure type” of an Array Aggregator module:
As you can see, the “Map” toggle on fields are used when you have an array. You can easily build an array variable to map to a field, by using an Array Aggregator module and select the “Target Structure Type” as the future field you want to map the array into.
2 Likes
If I iterate:
And I want to use in “Create JSON” module:
What do I put instead for map?
The array variable of the array aggregator.
2 Likes
But its not he same data structure. All I want from the iterator is the ID, I then supplement it with data from elsewhere (eg: Web Content Link)
To make this crystal clear. This is the input. It is one bundle with an array/collection of IDs:
I need this ID. There are X number of them.
Then I need to create a JSON Object using the Create JSON Module:
I need the ID from the first image above → templateVariantId
Then I need to create ImagePlaceholders with data from somewhere else.
The ask: Instead of manually creating one item at a time in the UI, using “Add item”
How can I map this programmatically, instead of create each item manually like so:
Hi @Arno_Nel
Is the image link you are putting same for every variant? Select JSON as target structure type in array aggregator and do the same mapping in array aggregator you are doing in json for one time. It will aggregate all the variants in your target structure type.
If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel
2 Likes