I have a function that I want to run on a time trigger every hour (in the test I have put it to minutes). However, it is not running unless I manually trigger it. Can anyone help me?
function setTrigger() {
ScriptApp.newTrigger("LiDCOcheck")
.timeBased()
.everyMinutes(1)
.create();
}
function LiDCOcheck() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ui = SpreadsheetApp.getUi();
var buttons = ui.ButtonSet.YES_NO;
var bed = ss.getRange("C2").getValue();
var due = new Date(ss.getRange("D2").getValue());
var time = new Date(ss.getRange("A2").getValue());
if (+due.getHours() == +time.getHours()) {
var lidco = ui.alert("It hsa been 24 hours since the LiDCO in Bed " + bed + " was calibrated. Is it still required?", buttons);
if (lidco == ui.Button.YES) {
ss.getRange("D2").setBackground('#ff9900');}
else {
ss.getRange("D2").setValue('Not Required')}
}
}