Search HoldMyTwist

Browse all posts

Make Iterator: process each item in a list

Make Free can take a list that's nested and break it into individual bundles, map each element, and check for the empty list case before the real action is bound.

A wooden conveyor separating aqua parcels one at a time into a brass tray

An array is just a series of values. The Iterator (opens in a new tab) in Make divides it into individual records (called bundles) that other modules can handle one at a time.

Before you start

First, you will need an account on Make. You can create a Make Free account (opens in a new tab) or login. For this exercise you can do it without integrating another app.

This Make Free demo scenario that's processing a fake shopping list. It's just using some of the built-in modules and not pushing any data out of make. Set your scenario to Inactive.

1. Create a list to practise with

  1. Scenarios > Create scenario
  2. Change the scenario name in the top left to Iterator shopping-list practice
  3. JSON > Parse JSON
    • Don't specify Data structure
    • Paste in the example for JSON string
  4. Save the module, and the scenario. Only select "Save anyway" if you get the message that your output is not being used.
  5. Run once
    • Again, if you get the warning that your output is not being used, select "Run anyway"
  6. Look at the JSON output for an items array.
Text to copy

{"items":[{"name":"Notebook"},{"name":"Pencil"},{"name":"Eraser"}]}

The outer braces is one object. The list is in the items field. That's different from an array at the top level. See how Parse JSON can already emit multiple bundles (opens in a new tab) for a top level array.

2. Split the items array

  1. Hide results. Flow Control > Iterator after Parse JSON.
  2. Click Array. In JSON 1 - Parse JSON, choose items[].
  3. Save. Run once. Deal with the "not using output" warning (same as above).
  4. Look inside the result bubble of the Iterator. In its Output, notice three bundles: Notebook, Pencil and Eraser.
Map the entire array items[]. Not just one name in it.

Full Make editor mapping JSON items array into the Iterator Array field

Full Make editor mapping JSON items array into the Iterator Array field

Map the entire array items[]. Not just one name in it.

Open full-size image

Full Make editor showing Iterator output bundles Notebook Pencil and Eraser

Full Make editor showing Iterator output bundles Notebook Pencil and Eraser
Open full-size image

Watch out

Each of them will trigger any module after the Iterator. So with this 3 items list you will get 3 runs of the next Tools module. Just check the count of output before adding any module that will send messages or create records or any modules that will cost more credits (with smaller sample to see the count of output).

3. Use the current item

  1. In tools add Set variable after Iterator.
  2. Name the variable as current_item.
  3. In Variable value select name from Flow Control 2 - Iterator.
  4. Save and hit Run once. Now you should have 3 operations in Tools result bubble. Click on each of them and see output.

Full Make editor showing three Tools operations after the Iterator

Full Make editor showing three Tools operations after the Iterator
Open full-size image

Notebook, Pencil and Eraser. If you choose a value from the original array you would be skipping the field of the current item.

If nothing runs after the Iterator

Look at your source array; this is a practice that gets to the Iterator for {"items":[]} but doesn't go through the next Tools module. Revert your 3-item example and try again.

If you don't have name in your mapping panel, try using the example again on source and Iterator and go back to Tools.

Make sure you see Array and the mapped array token there.

Why does the result show only one operation?

You can get multiple output bundles out of a single operation. For example, in this other Parse JSON example, you have an array of 3 items with names at top level.

So JSON is run once, and you get three bundles Notebook, Pencil, Eraser.

One Parse JSON yields three bundles. Make sure you count the number of entries in the Output before adding an Iterator. I have one Parse JSON with three outputs.

Make Parse JSON: one operation, three output bundles.

Make Parse JSON: one operation, three output bundles.

One Parse JSON yields three bundles. Make sure you count the number of entries in the Output before adding an Iterator. I have one Parse JSON with three outputs.

Open full-size image

The sample value on the map panel is Notebook. The following Tools > Set variable module has 1 mapped name field token. One run for each input bundle. It provides 3 bundles, therefore it will run 3 times (each time using the name from the provided bundle).

Look at Output from source result prior to implementing Iterator. You should implement an Iterator if you need to "split" an array field. If you already have separate bundles, you can pass them straight into the next module. Refer to the two input Parse JSON comparison to see exact inputs and process.

No account? Begin with Make Free (opens in a new tab) first. Review Free plan limits prior to the larger list scheduling.

Share this post