Is there some way to populate all the cells from 1 function call instead of 1 call for each cell?

162 views Asked by At

Here is my issue. I have a spreadsheet with multiple sheets, and each sheet has about 300-500 rows. I am using ScriptDb to store the data for each sheet.

What I am currently doing is calling a custom function in 300-500 cells in each sheet to populate certain cells with data, and what happens is that some will populate and the rest will error out saying i've queried the database too many times in a short period. Obviously having to query the database for each cell isn't the best solution.

How would I go about querying all the data for the current sheet and then having that data available to grab for each cell. What I've read is that you can't really have "global" variables in GAS, but have to use things such as CacheService or ScriptDB, which is what i'm trying to do. I'm just querying it too much.

Is there some way to populate all the cells from 1 function call instead of 1 call for each cell? What am I missing or what other solutions are there?

Just realized a similar question was asked earlier today: Google Spreadsheet Script invoked too many times per second for this Google user account

1

There are 1 answers

0
Zig Mandel On

Yes its possible. Simply return an array from your function. It will work like an arrayformula. Of course your cells would need to be contiguous.