I copied this script from Stackoverflow and changed it a little bit according to my requirements. It is supposed to send an email to an email address in Column D when the checkbox is checked in Column I.
But it is giving this error: "TypeError: Cannot read properties of undefined (reading 'source')" Here is my sample Sheet
`
function onEdit(e){
var sheet = e.source.getActiveSheet();
var cell = e.range;
Logger.log(cell.getColumn());
Logger.log(cell.isChecked());
//Check if the checkbox in column I(index 9) was checked
if(sheet.getName() == "Sheet2" && cell.getColumn() == 9 && cell.isChecked()){
//get current row values from column A to column G
var values = sheet.getRange(cell.getRow(),1,1,7).getDisplayValues().flat();
Logger.log(values);
var email = values[4];
var message = "Your application is Approved";
//Send email
MailApp.sendEmail({
to: email,
subject: "Your Application Status ",
htmlBody: message
});
}
}
`
I tried a script from Stackoverflow but It gave error.