Getting "Script invoked too many times per second" when running script in Google Spreadsheet

StackOverflow https://stackoverflow.com/questions/22447661

  •  15-06-2023
  •  | 
  •  

Frage

I have this scheduling application I implemented 4 years ago using Google Spreadsheets. It creates a schedule (or passport) for a science fair. Last year, to make it easier to understand, I created a simple script that looked up the room location to add to the activity:

function getRoom(project, map) {
  for (var i=0; i < map.length; i++) {
      if (map[i][0] == project)
          return(map[i][1]);
  }
  return("Not Found");
}

The Script is invoked close to 300 times on the worksheet as there are close to 40 schedules with 7 activities each. This worked fine till last year, started getting this error as I prepare the schedules for this year's science fair.

What quotas are this?

War es hilfreich?

Lösung

You haven't posted relevant code nor the actual error so I'll give a generic answer. 1) Read the apps script docs on how to write efficient gas code. 2) optimize often called functions. For example the map you showed could be rebuilt as a hash indexed by project. 2) if that still fails probably means you are running into a time quota since scripts can't run over 6minutes. If so you need to rewrite the code so it can process by parts and remember where it stopped so it can continue from there on next run. Run it manually until it completes all tasks or use a time trigger to run.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top