我提交了一个在提交表单时运行的脚本。当我使用带有e
参数的函数(例如下面的代码)时,脚本不起作用。我收到一条消息:ReferenceError: 'e' is not defined.
知道为什么吗?
function submitFormFunc(e) {
var items = e.response.getResponses();
var responses={};
for(var i = 0; i< items.length; i++) {
responses[items[i].getItem().getTitle()]=items[i].getResponse();
}
var responseTable = [];
var responseIndex = ["Timestamp","ID","question 1","question 2"];
responseTable.push(e.response.getTimestamp().toString());
responseTable.push(e.response.getId());
responseTable.push(responses["question 1"]);
responseTable.push(responses["question 2"]);
responseTable.push(FormApp.getActiveForm().getResponse(e.response.getId()).getEditResponseUrl());
SpreadsheetApp.openById("your spreadsheetId").appendRow(responseTable);
}
答案 0 :(得分:1)
您收到该错误是因为当您调用e
时,事件对象submitFormFunc(e)
尚未定义。这是调试时的典型情况,并且已从编辑器/调试器中调用参数化函数。