Sheet update after all the rows have been updated

:bullseye: What is your goal?

Hi All, I have a workflow where An Agent passes all the rows to be updated in a sheet module. The flows goes like this AGent->Json Parser-> Google Sheet-update row (updates Users sheet)
I want to add another Google sheet- update row module after this flow that updates another Config sheet only after all the updates in the earlier module have been complete. (If there any active Users left in the earlier sheet, update the Config to stop monitoring)

:thinking: What is the problem & what have you tried?

Currently the Config file is updated every time a User is updated in the User sheet.

I want the Config file to update after all the Users have been updated (so if all the Users are set to inactive, only then update the Config). Currently, the Config module acts per record- so the final state of the Config file is as per the active status of the last user updated. How do I make the Google sheet-update Config module to run only after all the records are updated by the prior module?
Also, the way I’ve done currently is - I have prompted the Agent to set the Config variables (next_monitoring_date, monitoring_on) based on the Active status of the Users and pass the entire structure in JSON format to the JSON Parser, but it keeps setting these variables per User state-:

{
“Monitor_next”: “No | Yes”,
“next_check_date”: “string”,
“results”: [
{
“Email”: “string”,
“Priority Date”: “MM/DD/YYYY”,
“Final Action Date”: “MM/DD/YYYY”,
“last notified date”: “MM/DD/YYYY”,
“Active”: “No | Yes”,
“Notes”: “string”
}
]
}

Also, I see that the Agent performs four different operations for 4 different rows, so the output of each operation is a single bundle with each row

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

1 Like

Hey there,

Add a search module that checks for active, follow it with a filter that allows the flow to continue only if no active members were found and then add the update module after it.

But that will again continue with config update per User record update. I want the second update (config update) to trigger only when the earlier module has updated all the records in Users sheet.

Is there a way I can create a dependent scenario that triggers only after the first scenario is entirely complete?

Or I can schedule the second scenario only for Config update 15 minutes later?

1 Like

You have multiple bundles. You need to “merge” them into one bundle, so that the next module only runs once. To do that, you’ll need an aggregator module.

Combining Bundles Using Aggregators

Every result/item from some module types (like Trigger / Iterator / List / Search / Match modules) can potentially and likely output more than one bundle. These multiple bundles will individually run subsequent modules once per bundle, which is not optimal in most cases:

  • one operation per bundle per module, which could lead to…
  • use of multiple credits per bundle per module (some modules use more than one credit)
View example screenshots

Aggregator Example

The “Search Rows” module runs one time, returning 999 results (999 bundles).

  • Without Aggregator: the tools module run 999 times (999 operations)


    (and if there are more modules, they run 999 times each)

  • With Aggregator: the tools module only runs 1 time (1 operation)

:warning: Warning: :police_car_light:
This can easily use your entire quota of credits if you are not careful or fail to understand this concept.

To “combine” multiple bundles into a single variable, so that you can process all of the items in a single operation, you’ll need to use an aggregator. Aggregators is a type of module that accumulates bundles and outputs one bundle (unless you are using “Group By”). An example of a commonly-used aggregator module is the Array aggregator module.

You can find out more about some other aggregator modules here:

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

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!

Mapping a Complex (Collection) Structure Into an Array Field

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 array field to map multiple items (collections) to it. Such fields initially may allow you to manually add individual items, but toggle the “Map” switch on, and you can map an array variable (from an Array Aggregator) containing multiple collections.

Simply select the respective “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).

:clipboard: Note: :light_bulb:
Other combinations of modules may also allow you to generate an array that matches a future module 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 solution may or may not look like this depending on requirements and actual data.

For more information, see “Mapping with arrays” in the Help Centre. I also suggest going through the Make Academy, which also covers the use of Iterators & Aggregators.

— @samliew

Hi @samliew ,

In my scenario, I’m using a google sheet before the Agent,

The output of the google sheet is multiple bundles (1 per row). The agent ultimately needs to update the rows back into the sheet (that’s why there is a sheet module after the agent). But I see that agent separates each bundle into a separate operation so there are 4 total operations (for each row)

Do you need to put an aggregator before the Agent? So google sheet (search row)→aggregator →agent→json parser→google sheet (update row)

1 Like

Hi @Amrita_007 ,

The issue occurs because Google Sheets → Update a Row processes data per bundle, causing the Config sheet to update for every single user. To avoid this, you should switch to a bulk update pattern and trigger the Config update only after all User updates are completed.

Below is the correct approach.
(You can refer to the screenshots I’m providing)

1. Agent → JSON Parser

  • Parse all user records as usual.

2. Array Aggregator

3. Google Sheets → Bulk Update Rows (Advanced)

This is the recommended approach to update records in bulk so the Config sheet runs only once after all user updates are completed.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

Hi @Msquare_Automation

Shouldn’t I be mapping JSON’s output to the Array Aggregator (as opposed to the original sheet the Agent reads from)? After all that’s what I want to update the sheet with (Active, last notified, and Notes fields are updated by AI Agent which passes it to the Jason parser)

Basically the Agent takes the records from the prior sheet, updates the values for Active, Last Notified and Notes fields, formats it via JSON parse, gives it to the aggregator which in turn is supposed to use that result to update rows.

But I think something is wrong with my mapping and the sheet is updated randomly.

JSON modules output:

1 Like

Hi @Amrita_007 ,

Could you please share the scenario blueprint? This will help us review the scenario in detail and better understand how the data is being processed.

Having this information will allow us to troubleshoot the issue more accurately and provide you with a clearer and more effective solution.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

Hi @Msquare_Automation

Here it is!

Please disregard the disconnected Gmail and google worksheet modules for now (the disconnected sheet module is supposed to be the Config file that needs to be added only after the last update rows module is complete).

Thanks a lot for your help!

Copy-Visa Bulletin Scan (copy).blueprint.json (165.6 KB)