Hi guys, i’ve been using from some time to now that script and it has been working wonders since then, but recently, i’ve found a error that i can’t seem to solve.
I’ve used it easily with many other documents, but i’m not sure what’s happening on this one. Whenever i try to run the script, i’m finding this error:
I haven’t coded much with GAS, but as far as i’ve understood, that error should be thrown when there’s no equality between the coda table headers and GDocs headers, but there is. Could someone help me?
Hi @Pedro_Jimenez - The error seems to be coming from this line:
var targetRowURLs = toWorksheet.getRange(2, rowURLIndex + 1, targetRows.length).getValues().flat();
I think Apps Script is throwing an error because targetRows.length
is zero, and you are trying to get a range with zero rows. My guess is either that you are trying to sync an empty table or perhaps something else is mis-configured in the script.
1 Like
Also weird stuff happens with that script if the sheet that you are trying to sync is a syncTable - aka not a normal coda native table but something that comes from a pack
Just thought Id throw that out there
The script should ideally use try() → catch(e) to avoid this failure. But there are other aspects of this script that may be problematic. I see that it inserts rows into the target range one at a time when updating rows. This is extremely slow and Google advises against this.
I typically avoid this approach by building the entire data grid in memory; it’s blistering fast and it requires only a single setValues() call to update the data. This also helps to avoid concurrent editing collisions that are possible when updates increase the syncing process.
Some might argue – what about cases where the grid is massive, like 100,000 rows? Trust GAS; it works.