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 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.
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.