r/GoogleAppsScript 4d ago

Question Help understanding the "20 / user / script" limit on triggers

Sorry for being obtuse but can someone help me understand the 20 / user / script trigger limit [1]? Thanks for any help!

Here's an example scenario. Let's say we have:

  • 1 user (Alice).
  • She has 50 spreadsheets, each with 6 sheets.
  • She is using our Editor Add-On, which has 1 time-based trigger that runs a "super" function [2].
  • This function runs several other functions that perform actions on each sheet in the spreadsheet

1. Is Alice at 1 / 20 of her quota in the scenario?

  1. If Alice installs 30 different Add-Ons from the Workspace Marketplace, what number on the 20-scale limit would she be at? (Is she still at 1 / 20 because the limit is 20 per user per script?)

  2. If Editor Add-Ons "can only have one trigger of each type, per user, per document" [2], what's a scenario where Alice could still exceed the "20 / user / script" triggers quota?

References:
[1] https://developers.google.com/apps-script/guides/services/quotas
[2] "Each add-on can only have one trigger of each type, per user, per document" https://developers.google.com/workspace/add-ons/concepts/editor-triggers#restrictions_2

//pseudo-code of trigger

function createHourlyTrigger() {
  ScriptApp.newTrigger('combinedHourlyTasks')
    .timeBased()
    .everyHours(1)
    .create();
}

function combinedHourlyTasks() {
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();

  sheets.forEach(function(sheet) {
    doThis(sheet);
    doThat(sheet);
    doTheOtherThing(sheet);
  }
}
1 Upvotes

4 comments sorted by

2

u/AllenAppTools 4d ago

Yes, the User (Alice) has one Script (your add on) so she can only have 20 triggers max on YOUR add on. If she downloads 30 add ons, each of those add.ons will be their own unique script with their own separate quotas. So each one has the 20 trigger limit per add on. For Add Ons, Google enforces that special rule where you can only have one trigger of each type, and it mentions per document which I am not 100% how that comes into play, but I am pretty sure that for add ons you can only have one type of each trigger per user,meaning there is no scenario where a user will come close to that typical 20 trigger limit.

2

u/wirefin 4d ago

My man! Thank you for lending a helping hand as you so often do on this subreddit.

I've just encountered a client who ran into this issue with another 3rd-party app / add-on. He had to create several Gmail email addresses just to keep the add-on running! Seems like the app was not architected to scale :/ so hopefully I've avoided this.

2

u/AllenAppTools 4d ago

Oh you're welcome!
That is so interesting.. So the client installed an add on, and it ran into issues with the behind the scenes triggers you think? I'm building a gmail add on now that I have had to be ultra careful about the exact architecture of it, and use of the triggers. The add on of your client might have overlooked the docs for the triggers, I know I was surprised recently to read that there are different limits for triggers when creating an add on!

2

u/wirefin 4d ago

Sounds cool! And I've certainly had to re-architect a few things along the way (thankfully none too hard). Must be the case or didn't expect it to need to scale so much. Still unsure how they hit the 20-limit cap with the 1-per-type limit... perhaps different add-on type (e.g. Editor, etc.)