Reputation: 29441
I created a Google Script
to make automatic forms. I'd like to make it unaccessible before a given date but I can't find any way to do it. Even from the Google Doc
Upvotes: 0
Views: 2239
Reputation: 45740
The documentation shows Form.setAcceptingResponses()
, which you can use to toggle your form on & off. Set up such a function as a time-based trigger.
But you'll need to workaround the fact that container-bound Form scripts cannot have time-based triggers. (See Issue 3431, and star it to increase it's priority.)
As a simple work-around, create a stand-alone script with these functions in it, and specify the ID of your form:
/**
* Specify the form to operate on
*/
var formId = '--form-id--';
var form = FormApp.openById(formId);
/**
* Set this up as a time-based trigger to open your form at
* a specific date & time.
*/
function startAcceptingResponses() {
form.setAcceptingResponses(true);
}
/**
* Set this up as a time-based trigger to close your form at
* a specific date & time.
*/
function stopAcceptingResponses() {
form.setAcceptingResponses(false);
}
Then use the "Resources" menu to add time-based triggers and set up notifications, as described here.
Finally, make sure you've set the form starting state by clicking Accepting or Not Accepting.
To use this from your form-creation script, you need to use a TriggerBuilder to create the trigger.
For example:
// Creates a trigger that will run at noon on
// Jan 14, 2014 (+/- 15 min)
ScriptApp.newTrigger("startAcceptingResponses")
.timeBased()
.atDate(2014,1,14)
.atHour(12)
.create();
Upvotes: 1