To turn off Google form responses after a certain number of responses, you can use the below Apps Script code:
function shutdownForm(maxResponses) {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(false);
}
function onFormSubmit(e) {
var form = FormApp.getActiveForm();
var responses = form.getResponses().length;
var maxResponses = 10; // Replace 10 with the maximum number of responses you want to allow
if (responses >= maxResponses) {
shutdownForm(maxResponses);
}
}
To shut off the form at a specific date and time, you can use the following code:
function shutdownForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(false);
}
function scheduleFormShutdown() {
var form = FormApp.getActiveForm();
var shutdownDate = new Date("January 1, 2021 00:00:00"); // Replace with the date and time you want to shut off the form
if (new Date().getTime() >= shutdownDate.getTime()) {
shutdownForm();
}
}