How can I prevent form submissions until previous

2019-07-20 22:11发布

问题:

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:

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