Reputation: 21
i looked at the google app script installable trigger docs online (https://developers.google.com/apps-script/support) , and one of the examples shows how 2 create 2 time triggers.
function createTimeDrivenTriggers() {
// Trigger every 6 hours.
ScriptApp.newTrigger('myFunction')
.timeBased()
.everyHours(6)
.create();
// Trigger every Monday at 09:00.
ScriptApp.newTrigger('myFunction')
.timeBased()
.onWeekDay(ScriptApp.WeekDay.MONDAY)
.atHour(9)
.create();
}
My code:
function createTimeDrivenTriggers() {
// Trigger every 1 hours.
ScriptApp.newTrigger('MainFunctionDaily')
.timeBased()
.everyHours(1)
.create();
// Trigger every Friday at 13:00.
ScriptApp.newTrigger('MainFunctionWeekly')
.timeBased()
.onWeekDay(ScriptApp.WeekDay.FRIDAY)
.atHour(13)
.create();
}
However when i try to create the triggers, i get an error:
This add-on has created too many time-based triggers in this document for this Google user account
Please advise
Upvotes: 2
Views: 3105
Reputation: 38180
UPDATE: The documentation for add-ons was moved. In this case the new location of the below referred restriction is https://developers.google.com/gsuite/add-ons/concepts/editor-triggers
From https://developers.google.com/apps-script/guides/triggers/installable#limitations (emphasis mine):
Limitations
Several limitations apply to installable triggers in add-ons: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.
The alternatives are
Upvotes: 5
Reputation: 1
Two possible issues:
You will probably need to choose one of your triggers only but you can try this:
function createTimeDrivenTriggers() {
// Trigger every 6 hours.
ScriptApp.newTrigger('myFunction')
.timeBased()
.everyHours(6)
.create();
}
function createTimeDrivenTriggers() {
// Trigger every Monday at 09:00.
ScriptApp.newTrigger('myFunction')
.timeBased()
.onWeekDay(ScriptApp.WeekDay.MONDAY)
.atHour(9)
.create();
}
Upvotes: -2