My colleague and I are teachers and do not have much background in programming. We have pieced together a script that creates a Google Calendar event from a Form fed spreadsheet; however, we cannot get the trigger to work.
Many have suggested moving away from time-based triggers because they can be unreliable, so we'd like to write our own trigger. After researching, it seems an onEdit(e) trigger would be best, but we can't get it to work conditionally. We'd like our script only to run if the approval column says "Yes" (column 13).
From what I've seen, it looks like we should probably be doing this completely differently (maybe with getValue), so I'm calling on everyone here for help. It seems like it should be so simple! FYI, findRow works and makes the calendar events, so we just need findRow to run if column 13 is "Yes."
Any help you can give is greatly appreciated. Here is the code:
function onEdit(e) {
var range = e.range;
var colToCheck = 13;
if (colToCheck = "Yes");
findRow;
};
I don't know what findRow() does. But I think this is what you were trying to accomplish.
function onEdit(e)
{
var ss= e.source;
var sht=ss.getActiveSheet();
var range = e.range;
var row = range.getRow();
var approval = sht.getRange(row,13).getValue();
if (approval=="Yes")
{
findRow();
}
}
By the way when I first started studying triggers, I wrote a routine that made a log entry every time I got a trigger and after exactly three days of one hour triggers I had 72 log entrees so I would say that they are very reliable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With