gpt4 book ai didi

javascript - 为什么 bool 值被记录为复选框在记录时未定义?

转载 作者:行者123 更新时间:2023-11-30 13:51:05 25 4
gpt4 key购买 nike

我正在尝试记录检查变量的值,它是第 11 列,它是一个复选框,如果它被选中或未被选中,它应该显示为 true 或 false。但是,我收到一条日志,指出该值未定义,我不太确定这是为什么。

有人可以帮忙吗?我已发表评论供您引用。

function sendEmail() {

//setup function
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];


//problem here
var check = CurrentRow[11];
Logger.log(check)




if (EmailSent == "sent")
continue;

//set HTML template for information
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 = "email@email.org.au" + "," + "email@email.org.au";

var Subject = "CT IT feedback";


MailApp.sendEmail({
to: SendTo,
cc: "",
subject: Subject,
htmlBody: message,
});
}

最佳答案

如上所述,如果您要从工作表中获取值,则需要考虑使用嵌套 for 循环进行循环。我不熟悉您在代码段中使用的那些功能,但为了学习,我在下面提供了一个如何逐步完成工作表的示例。

请参阅下面的示例。

var sheet = [
[1,2,3,4],
[5,6,7,8],
[9,10,11,12]
];

// Think of the above array as your sheet.
// You will step go 1, 2, 3, 4 and then step down a row
// to 5, 6, 7, 8 and so on.

var rows = sheet.length;
var rowCount;

for(var i = 0; i < rows; i++) {
rowCount = 0;
for(var j = 0; j < sheet[i].length; j++) {
rowCount += sheet[i][j];
}
// Finished calculating the row.
console.log(rowCount);
}

关于javascript - 为什么 bool 值被记录为复选框在记录时未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58230081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com