Home > Software engineering >  Google Apps script: time-driven trigger not triggering
Google Apps script: time-driven trigger not triggering

Time:05-17

I have an issue with a time-driven trigger in Google Apps script: It should be triggered once a week on Saturday and then call another function named: saveregular()

Please see the code below:

function createTimeDrivenTriggers() {
  // Trigger every Saturday at 06:00
  ScriptApp.newTrigger('saveregular')
      .timeBased()
      .onWeekDay(ScriptApp.WeekDay.SATURDAY)
      .atHour(6)
      .create();
}

Is there an error in the code? Am I missing something obvious? Do I have to enable trigger events elsewhere?

Thanks a lot for your help!

CodePudding user response:

Issue:

As suggested by TheMaster's comment, and as shown in the docs:

Frequency is required if you are using atHour() or nearMinute()

Explanation:

atHour specifies the hour a trigger runs, but you also have to specify whether that happens every day, every week, or what have you.

For example, if you wanted to fire this every day, you should add everyDays(1) (see everyDays).

You can also directly create or modify the triggers in the dashboard here

  • Related