2015-09-07 94 views
0

由于昨晚我的脚本无法正常工作,因为onFormSubmit触发器不工作。既然它在工作之前,突然停止,我猜这是在谷歌的问题,但我一直在改变很多事情,并希望确保它不是我错过了我做错了。Apps脚本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()的'超出最大执行时间'错误获取'故障摘要'电子邮件。

回答