【发布时间】:2015-12-03 00:18:56
【问题描述】:
从昨晚开始,我的脚本无法正常工作,因为 onFormSubmit 触发器不起作用。由于它之前工作并突然停止,我猜这是谷歌的问题,但我一直在改变很多东西,并想确保不是我错过了我做错的事情。
这是创建表单并设置触发器的函数:
function newForm(ss)
{
var scriptProperties, form, id, url;
scriptProperties = PropertiesService.getScriptProperties();
form = FormApp.create('Form');
form.setConfirmationMessage('Thanks!');
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss);
form.setShowLinkToRespondAgain(false);
form.addTextItem().setTitle('Name').setRequired(true);
form.addTextItem().setTitle('Email').setRequired(true);
id = form.getId();
url = form.getPublishedUrl();
scriptProperties.setProperty('FORM_ID', id);
scriptProperties.setProperty('FORM_URL', url);
ScriptApp.newTrigger('bookSlot')
.forForm(id)
.onFormSubmit()
.create();
return id;
}
这是应该在 onFormSubmit 上运行的函数:
function bookSlot(e)
{
Logger.log('this');
var scriptProperties, itemResponses, response, name, email, formChoice, index;
scriptProperties = PropertiesService.getScriptProperties();
itemResponses = e.response.getItemResponses();
response = itemResponses[2].getResponse();
name = itemResponses[0].getResponse();
email = itemResponses[1].getResponse();
formChoice = JSON.parse(scriptProperties.getProperty('FORM_CHOICE'));
index = formChoice.indexOf(response);
Logger.log('index is ' + index);
}
当我签入项目的触发器时创建了触发器本身,似乎一切都应该到位,但是当我提交表单时没有发生任何事情。我开始收到带有 formSubmit 触发器的 bookSlot() 的“超过最大执行时间”错误的“失败摘要”电子邮件。
【问题讨论】:
标签: google-apps-script google-sheets google-forms