提问者:小点点

应用程序脚本onFormSubmit停止工作


从昨晚开始,我的脚本就不起作用了,因为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;
}

这是应该在FormSubmit上运行的函数:

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);
}

触发器本身是在我签入Project的触发器时创建的,似乎一切都应该就位,但当我提交表单时什么都没有发生。我开始收到带有“超过最大执行时间”错误的“失败摘要”电子邮件,用于formSubmit触发器的bookSlot()。


共1个答案

匿名用户

如果超过配额,脚本将停止工作。您可以在此链接中找到所有配额:https://developers.google.com/apps-script/guides/services/quotas