Save values in Array and iterate

Hi there,
I need support to understand better how to work with arrays.

Here an example of a scenario.

I have multiple Google Sheet with customer information (like, first name, last name, email, company, etc). All the Google Sheet have different organization and columns.

Every time the search into Google Sheet run, will find multiple rows.

I need to normalize everything parameters and than add the values into Mailchimp.

I create a scenario like this:

  • a router with a branch for each Google Sheet
  • in each branch, a “sarch” module for Google Sheet
  • a “set multiple vars” module that save the values
  • a “get multiple vars” module to get the values
  • a “add/update subscriber” module that save the values into MailChimp.

The point is that the scenario run sequentially so the variables will be overwrited all times, and only the last value will be saved in MailChimp.

I know (but only theoretically) that I can save all the values in an array and use it to iterate the data into mailchimp.

But I don’t know how to do that.

Can someone help me?

Thanks!

Mattia

Welcome to the Make community!

Every result (item/record) from a search 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.

Links

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

2 Likes

Thanks for your reply, I’ve added the iterator and a set var that I need to recover the data for the next step.

But seems it overwrite the data, and not add the new set of data to the existing array.

Where I’am wrong?

In your first Set Variable module, for the “Variable Name” field, you name it “array1”.

In your second Set Variable module, for the “Variable Name” field, you name it “array2”.

Then, in the final route, use the “Get Multiple Variables” to get variables “array1” and “array2”.

In your Mailchimp field, merge the arrays using the built-in function merge:

{{ merge(array1; array2) }}
3 Likes