How do i send the right email in my scenario?

Hi there,
i am struggling to understand how can i fix the problem of my scenario.
I saw already that someone asked for the same question some times ago, but the given solution somehow doesn´t work for me (or i am not able to let it work).
Here my scenario

how do i avoid to send 10 email (same amount of the operation of the Text Aggregator)? i need only 1 email, with the results of the last operation of the text aggregator.

Someone can maybe show me the trick?

2 Likes

Hey @Stefano_Sorrentino – Just change the source module in the text aggregator to select the iterator as the source module instead of the data store.

I hope by doing this, your issue will be resolved.

You’re getting 10 emails because the Data Store returns 10 records, causing the scenario to loop 10 times. Send the screenshot of the first data store settings and I will advise you from there

1 Like

Hi @RBalani, but i need only the data that are the result of the “search records”, it will work also like that?

Hi @kelvin_Gitau that´s absolutely true, i have 10 record written in the db from the Iterator, is only a test enviroment, in the prod one i will problably have 100s of records, but in any case here the screenshot:

Changing the source module of the Text Aggregator will not impact this.

However, if you’re using the value from Data Store 22 in the email, it might have an effect.

Could you please share a screenshot of the Gmail module mapping?

Hi, i can confirm that in the email i am using the values directly from the text aggregator

i tried to modify the Source module in the text aggregator, it sends only 1 email now, but with the wrong data. Before was sending 10 emails with at least 8 of them with the right data.

Welcome to the Make Community!

Looks like you’ll need a second Text Aggregator to close the Iterator “loop”.

Iterator modules can possibly return more than one bundle, and it looks like in your screenshot, that returns 10 bundles.

Setting the Correct Aggregator Source

You need to set the “Source Module” field of the aggregator to where the bundles are coming from. This is usually an iterator module, but can also be a search/list/repeater module, or even the trigger module!

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. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.

You can find out more about the other types of aggregator modules here:

Question: Which is the best aggregator do you think you’ll need for your use-case?

Mapping a Specific Structure Into a Complex Field

If you have an array of collections, in programming terms, this is called an array of objects, or an array with non-primitive data types (“complex”).

The Array Aggregator module is very powerful because it allows you to build a new complex array of collections that matches a later module’s field to map multiple items (collections) to it. Such fields initially would allow you to manually add items, but you can toggle the “Map” switch to the “on” state and map a whole array into a single field.

This is done by selecting the “Target structure type” in an Array Aggregator module.

As you can see from the above example, the “Map” toggle on complex fields are used when you have an array variable (like from an array aggregator). Other combinations of modules may also allow you to generate an array that matches a future field’s array structure, like “Aggregate to JSON + Parse JSON”, or “Create JSON + Parse JSON”, but this is an advanced topic.

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

Example

Here is an example of how your scenario could look like:


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

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

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

@samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!