How can I prevent form submissions until previous

2019-07-20 22:47发布

I have written a form script that eliminates the chosen answer. This means it has to process a function onFormSubmit. While the script works, the end-user has to wait 30 seconds before they click resubmit or else the choice will not be eliminated.

Is there a way I can prevent submissions until the onFormSubmit function is completed?

1条回答
霸刀☆藐视天下
2楼-- · 2019-07-20 23:10

I was able to accomplish this (thank you AdamL) using setAcceptingResponses(enabled).

function onFormSubmit(){
  var af = FormApp.getActiveForm();
  var defaultClosedFor = af.getCustomClosedFormMessage();
  af.setCustomClosedFormMessage("The form is currently processing a submission, please refresh the page.");
  af.setAcceptingResponses(false);


<put your script stuff here>


   af.setAcceptingResponses(true);
  af.setCustomClosedFormMessage(defaultClosedFor);
}
查看更多
登录 后发表回答