【发布时间】:2020-11-16 04:54:08
【问题描述】:
我一直在试图弄清楚这一点,但时间最长,我什么也没有。怎么解决这个错误,请帮忙
function myFunction() {
var form = FormApp.openByUrl('form');
var allItems = form.getItems();
var doc = SpreadsheetApp.getActiveSpreadsheet()
var sheet = doc.getSheetByName("name");
var last = doc.getLastRow();
var data = sheet.getRange(1,1,last,8).getValues();
for(i=0,h=1; i<data.length, h<allItems.length;++i,++h){
if(data[i][2] == 0 && h==4){ //this where the error messages comes up for the "2"
var newText = allItems[h].asMultipleChoiceItem();
var title = newText.getTitle();
var newTitle = newText.setTitle(title+" (Sold out)");
}
}
}
【问题讨论】:
-
这意味着“数据”对象是未定义的。检查工作表的名称是否正确(“名称”)或您获得的值的范围(例如 var “last”)。您能否在 var sheet 行之后添加 Logger.log(sheet)?
标签: javascript google-apps-script google-sheets undefined typeerror