I don't understand what are the real limits of App Script time-based triggers.
Let's say I need to create two different time based triggers on a document for a user using my add-on. I want to use two triggers because it is for two different features and they need different internals & management.
I did a simple test:
function testTriggers() {
var n = 10;
SpreadsheetApp.getUi()
.alert('Creating triggers' + n);
createTriggers(n);
}
function createTriggers(n) {
for(var i = 0; i < n; i++){
ScriptApp.newTrigger('myTriggerFunction' + i)
.timeBased()
.everyHours(i+1)
.create();
}
}
function myTriggerFunction(){
console.info("STARGED trigger");
for(var i = 0; i < 10; i++){
Utilities.sleep(10 * 1000);
console.info('time: ' + i);
}
console.info("ENDED trigger");
}
function myTriggerFunction0() {
myTriggerFunction();
}
function myTriggerFunction0() {
myTriggerFunction();
}
function myTriggerFunction1() {
myTriggerFunction();
}
function myTriggerFunction2() {
myTriggerFunction();
}
function myTriggerFunction3() {
myTriggerFunction();
}
function myTriggerFunction4() {
myTriggerFunction();
}
function myTriggerFunction5() {
myTriggerFunction();
}
function myTriggerFunction6() {
myTriggerFunction();
}
function myTriggerFunction7() {
myTriggerFunction();
}
function myTriggerFunction8() {
myTriggerFunction();
}
function myTriggerFunction9() {
myTriggerFunction();
}
When I make testTriggers run I receive the error:
This add-on has created too many time-based triggers in this document for this Google user account.
And I can see in my triggers window that only the first trigger was created, on myTriggerFunction0.
Is this the expected behavior ? if I check the documentation I see nothing about this, on the quota page they only tell you: 20 user / script, which I think is for every document the add-on is installed on at this point.
By looking on stack I've found this answer where it seems that in the past documentation it was stated:
Each add-on can only have one trigger of each type, per user, per document. For instance, in a given spreadsheet, a given user can only have one edit trigger, although the user could also have a form-submit trigger or a time-driven trigger in the same spreadsheet.
Has something changed ?
Also, I've a question about the 90 min / day total runtime stated in the quota page: I think this limit is user based, but is it also document based ? Will 2 triggers on 2 different documents consuming the same "execution time quota" ?