samedi 16 octobre 2021

Send emails when checkbox is ticked

Hello so I wanted to send an e-mail when a checkbox is ticked but can't seem to figure out what the problem is with my script. It always returns as "No clue" as seen on my else statement.

Column M: email Column N: email body Column P: checkbox

function onCheckboxEdit(e) {
  var source = e.source;
  var sheet = source.getActiveSheet() ;
  var range = e.range;
  var row = range.getRow();
  var column = range.getColumn();
  console.log("column:: ", column);

  var targetRange = sheet.getRange(row, 13, 1, 4);
  var targetValues = targetRange.getValues();
  console.log("targetRange:: ", targetValues);
  var recipient = targetValues[0][12];
  var checkboxValue = targetValues[0][15];
  var body = targetValues[0][13];
  var subject = "new triggered message"

  if(column = 16 && checkboxValue  == true) {
    console.log("checkbox marked true")

    GmailApp.sendEmail(recipient, subject, body)

  }else if (column = 16 && checkboxValue == false) {
    console.log("checkbox marked false")
  }else {
    console.log("No clue")
  }
}



Aucun commentaire:

Enregistrer un commentaire