Conditional Array

Hi All,
I will do my best to explain my issue and hoping you can help.
I have an Iterator that returns a group of products. Some have options and some do not:

I then get to the Array Aggregator and map the fields as per below. This all works perfectly. My problem is the highlighted field below.

I need to map this field based on the Options in the first screen shot. If the Options are empty, I need to ignore them. However, if there is an option value, then I need to map the value.

The Attribute requires a Key and a Value. The key can be anything (I have been using Options), and the value is the text.
I can create Options with an empty value, but Ideally I do not want to create the key or value if the Option is empty is screenshot 1.

I hope that makes sense. Any help would be appreciated.

Thanks
Ben

Welcome to the Make community!

You can try splitting the “options” value by newline in an Iterator module, then use an array aggregator to map into the options field.

Combining Bundles Using Aggregators

Every result (item/record) from trigger/iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, 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.

Question: Which type of aggregator do you think you’ll need?

Mapping a Specific Structure Into a Complex Field

The Array Aggregator module is very powerful because it allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

This is done using the “Target structure type” field in an Array Aggregator module.

Here is an example:

As you can see, the “Map” toggle on complex fields are used when you have an array. You can easily build an array variable to map to a future module’s field, by using an Array Aggregator module and select the “Target Structure Type” as the future module’s field you have mapped the array into.

Question: Are you mapping your array into a field that accepts more than one “item”?

Example

Here is an example of how your scenario could look:

This is just an example. Your final solution may or may not look like this depending on your requirements and actual input data.

For more information, see the “Mapping with arrays” link below. You should also do the Make Academy, which also covers the use of Iterators & Aggregators.

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.