In my code, I'm attempting to log the value of a variable named check, which corresponds to column 11 in a spreadsheet. This variable is meant to represent the state of a checkbox (true or false) based on whether it's been ticked or not. However, when I try to log this value, I keep getting an 'undefined' error message and I'm unsure why.
If anyone could provide some insight into this issue, I would greatly appreciate it. I've included a comment for your reference within the code snippet below.
function sendEmail() {
// Function setup
var ActiveSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var StartRow = 2;
var RowRange = ActiveSheet.getLastRow() - StartRow + 1;
var WholeRange = ActiveSheet.getRange(StartRow,1,RowRange,11);
var AllValues = WholeRange.getValues();
var message = "";
for (i in AllValues) {
var CurrentRow = AllValues[i];
var EmailSent = CurrentRow[13];
// Issue arises here
var check = CurrentRow[11];
Logger.log(check)
if (EmailSent == "sent")
continue;
// HTML template for email content
message +=
"<p><b>Timestamp by: </b>" + CurrentRow[1] + "</p>" +
"<p><b>Requester Email: </b>" + CurrentRow[2] + "</p>" +
"<p><b>Star Rating: </b>" + CurrentRow[3] + "</p>" +
"<p><b>Request Category: </b>" + CurrentRow[4] + "</p>" +
"<p><b>Description: </b>" + CurrentRow[5] + "</p>" +
"<p><b>Label: </b>" + CurrentRow[6] + "</p>" +
"<p><b>Ticket ID: </b>" + CurrentRow[7] + "</p>" +
"<p><b>Comment: </b>" + CurrentRow[8] + "</p>" +
"<p><b>Status: </b>" + CurrentRow[9] + "</p><br><br>";
var setRow = parseInt(i) + StartRow;
ActiveSheet.getRange(setRow, 13).setValue("sent");
}
var SendTo = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="32575f535b5e72575f535b5e1c5d40551c5347">[email protected]</a>" + "," + "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85e0e8e4ece9c5e0e8e4ece9abeaf7e2abe4f0">[email protected]</a>";
var Subject = "CT IT feedback";
MailApp.sendEmail({
to: SendTo,
cc: "",
subject: Subject,
htmlBody: message,
});
}