0

I currently have a function in google app script which is used to split a price list into different spreadsheets by manufacturer and then rearrange the data in each new spreadsheet. My code works fine apart from the fact that I'm hitting the maximum execution time limit. Would it be possible to split the data up into chunks and then with one click have app script perform separate executions of the same function on each chunk of data (so that the time limit isn't exceeded)? So it would be like this:

execute
myfunction(chunkA){}
stop execution
execute
myfunction(chunkB){}
stop execution
etc.

but without having to manually click run each time and change the input. I've tried a couple of methods so far, such as the property method shown here: link but this still runs everything under one single execution so I end up over the limit again. Any guidance you could give me on this would be much appreciated!

  • These may help https://github.com/tanaikech/RunAll or https://github.com/brucemcpherson/gasThreader but you may not need any of these. You probably just need to optimize your existing script. See [tag info page](https://stackoverflow.com/tags/google-apps-script/info) for "Best practices" – TheMaster Jun 17 '20 at 15:53
  • Thanks a lot for the links! I'll have a read through and give them a go. Overall the script is quite fast and relatively well optimised (I think!); my issue is that it uses the 'createFile(blob)' method, which slows the whole thing down a lot. – Rowan Ibbeken Jun 17 '20 at 16:25
  • Does this answer your question? [Exceeded maximum execution time in Google Apps Script](https://stackoverflow.com/questions/7854573/exceeded-maximum-execution-time-in-google-apps-script) – Iamblichus Jun 18 '20 at 07:59
  • Thanks for the link, I'll try both approaches and see which one works for me. – Rowan Ibbeken Jun 18 '20 at 10:35
  • Thanks a lot TheMaster, the RunAll library worked a charm and now my code is much much faster! – Rowan Ibbeken Jun 19 '20 at 20:10

0 Answers0