Writing the onEdit Trigger in Google Apps Scripts
My colleague and I are teachers and I have little programming experience. We've put together a script that creates a Google Calendar event from a spreadsheet filled with a Form; however, we cannot get the trigger to work.
Many have suggested dropping temporary triggers because they might be unreliable, so we would like to write our own trigger. After research, it seems like a trigger onEdit(e)
would be the best, but we cannot make it work conditionally. We only want our script to execute if the assertion column says "Yes" (column 13).
From what I've seen, it looks like we should probably be doing this in a completely different way (perhaps with getValue
), so I encourage everyone here to help. It seems like everything should be that simple! FYI, it findRow
works and does calendar events, so we need to findRow
fire 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;
};
source to share
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 learning about triggers, I wrote a routine that made a log entry every time I received a trigger, and after exactly three days of one hour of the trigger, I had 72 log entries, so I would say they are very reliable.
source to share