first off; @Scott_Collier-Weir has done a GREAT job of explaining clearly how to use google script to achieve this magic trick - well done CodaGuy!
@Omar_Mhammedi, you ask a very good question that i want to tackle, based on my experience with several different clients and approaches to this;
where to use a Pack vs Integration platforms (Make, Zapier… etc) vs Google Script (and/or VBA)?
we have found that the GREATEST benefit to accrue from using Coda to automate workflows comes from the SELF-SERVICE aspect of using no-code in general and Coda in particular.
when makers are able to create their own automations BY THEMSELVES without depending on expertise from the IT department or other developers - then they enjoy HUGE benefits. they harness their own business expertise and their previous experience with spreadsheets and create, modify and share useful automations faster, cheaper and with greater agility than any other method.
but when Coda is unable to achieve the needed functionality by itself, they must exploit external tools to overcome this problem.
if they DONT have experience with PROCEDURAL CODE (eg VBA, JavaScript, Python) then we direct them to the family of integration platforms such as Make or Zapier (and others) where they can continue to enjoy the SELF-SERVICE benefits of those ‘no-code’ tools. they can achieve a LOT with these tools without needing to write procedural code.
if they DO have some experience writing procedural code, or they have someone on their team who can do so; then they have a range of options as follows;
many Excel whizz-kids have experience writing macros in VBA (MS Visual Basic) and we provide them with our VBA pack that translates VBA code into Coda actions. so they remain self-sufficient.
many Google Sheets users have experience writing macros in Google Application Script (GAS) ,a dialect of JavaScript, and we encourage them to exploit @Eric_Koleda’s pack that lets them write integration applets in GAS, which can do external integrations.
finally, if a user has a LOT of experience with advanced JavaScript, JSON and APIs; then we show them how to develop Coda Packs to achieve the integrations they require. (We also build such Packs for our clients but that breaks the SELF-SERVICE aspect of using Coda.)
so in summary (TL;DR)…
we choose the option that maximises the SELF-SERVICE paradigm of using no-code tools, based on the level of expertise the users already have (or can readily acquire). we try to avoid creating any DEPENCENCIES on external experts as much as possible.
respect
max