Reputation: 522
I am wanting to run a process overnight if data on a specific sheet is updated. I cunningly thought of installing a trigger for that night if the criteria match. I don't want to run the trigger every night regardless and look for a 'changed' attribute stored somewhere because a new file is created every year and the ending of the overnight processing is somewhat flexible... so if no data was updated, don't even check.
I have this:
function onEdit(e) {
try {
var range = e.range;
var sheet = range.getSheet();
var sheet_name = sheet.getName();
Logger.log("Edit on sheet '" + sheet_name +"'");
if(sheet_name == C_SHEET_FORECAST) {
installOvernightTrigger();
}
} catch(x) {
Logger.log(x);
} finally {
endLog();
}
}
What I get in the log is Exception: You do not have permission to call newTrigger
.
I appreciate that without careful handling this could climb up itself and possibly melt google, but is there a way to do what I want?
Upvotes: 0
Views: 215
Reputation:
Simple triggers (such as naming a function onEdit) cannot do anything that requires authorization, which includes creating other triggers.
Rename onEdit
to something else and create an installable trigger for it.
Upvotes: 1