我正在编写一个脚本,以获取最近提交的表单。我在网上找到了一个原始示例...
function onSubmit() {
// Open a form by ID and log the responses to each question.
var form = FormApp.openById('1G3e4FTYlsJUl5mKX2v1pYWauG1FO5IUPDIOI6P4hUoA');
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var itemResponses = formResponse.getItemResponses();
for (var j = 0; j < itemResponses.length; j++) {
var itemResponse = itemResponses[j];
Logger.log('Response #%s to the question "%s" was "%s"',
(i + 1).toString(),
itemResponse.getItem().getTitle(),
itemResponse.getResponse());
}
}
}
我已将其修改为...
function onSubmit() {
// Open a form by ID and log the responses to each question.
var form = FormApp.openById('1G3e4FTYlsJUl5mKX2v1pYWauG1FO5IUPDIOI6P4hUoA');
var formResponses = form.getResponses();
var last_response = formResponses[formResponses.length - 1];
Logger.log(last_response.val)
}
当我查看上述脚本的日志时,我得到
undefined
。如何输出last_response的值?