I have two functions that are responsible for starting and stopping the execution of my script from UI.
function runScript() {
stopScript();
ScriptApp.newTrigger("start").timeBased().everyHours(1).create();
}
and
function stopScript() {
let triggers = ScriptApp.getProjectTriggers();
for (var i = 0; i < triggers.length; i++) {
ScriptApp.deleteTrigger(triggers[i]);
}
}
They both are triggered by the UI for which I'm using this piece of code:
function onOpen(e) {
let sheetUi = SpreadsheetApp.getUi();
sheetUi.createMenu('Menu')
.addItem('Run', 'runScript')
.addItem('Stop', 'stopScript')
.addToUi();
}
They work as expected: stopScript() remove the old time trigger and runScript() create a new one.
Once I run the function runScript() a new time trigger is created and I can see it in my dashboard. However, the time trigger never executes the script. For example, for the past 2 days, the time trigger which was set to execute the script every hour didn't execute it even once. I don't understand why this is happening.
The script can be used from any Google Sheet. I tried any solution I found on the internet and here but it keeps not running. I'm out of options.
Am I missing something?
function start(). Do you have such a function and if yes - what is its content? - ziganotschkastart()which is working correctly. Unfortunately, I can't share many details due to NDA. I should probably mention that I don't receive any errors either. Edit:startis my entry function, but I don't think that's a problem. The time trigger doesn't fire the function at all - Dimitar Dzhurenovhttps://script.google.com/home/triggers, select the trigger of interest and click on the three vertical dots on its right side - you can see "Executions" and "Failed Executions". If you click on "Failed Executions", you can see the list of all failed executions and clicking on the word "Failed" will show you the related "Stackdriver logs" containing the error message / exception. - ziganotschkaLast run&Error ratestays empty for my trigger athttps://script.google.com/home/triggersfor the past 2 days - Dimitar Dzhurenov