简体   繁体   中英

GAS - Execution time-out

I have a spreadsheet that needs to 'setValue' to about 2000 rows. The problem is, after awhile, I get time-out.

So I'm looking for a solution to split up the job.

I'm thinking of creating a time-based trigger, possibly to start off where the last row or timeout ended. But I can't figure how to get trigger unique ID.

function triggerList() {

  ScriptApp.newTrigger('populateList')
   .timeBased()
   .after(5 * 60 * 1000) // run every 5 mins. Script will time-out.
   .create();

}

function deleteTrigger() {
 // delete the above trigger
 var triggers = ScriptApp.getProjectTriggers();

 for (var i = 0; i < triggers.length; i++) {
   Logger.log(triggers[i]);
 }
}

There is a similar topic on this but i don't quite understand.
What happens when I "sleep" in GAS ? (execution time limit workaround)

Anyone has suggestions, workarounds?

Put all of your data into a two dimensional array first, then set all the values at once. Each inner array is a row, each element of each inner array is a cell in a new column.

Set Values Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM