Online Registration for Events/Programs at the Library


#1

We create a Form in Google to track registration for some of our Events. (for example in case of “limited seating” or supply issues…)

Patrons access the form from a link on the Events page.

We have found a “script” that manages form availability. (Open/close and limit registrations) This is cool. I’ve pasted the script below. To use it, create your form in Google Forms editor, then use the 3 vertical dots and choose ‘script editor’. Paste the script below. (change Dates and such as necessary.) On the Script Editor menu choose Run and Initialize.

/* copy the script below this line, to the end of this message */

FORM_OPEN_DATE = “2016-06-15 01:00”;
FORM_CLOSE_DATE = “2016-06-22 12:00”;
RESPONSE_COUNT = “85”;

/* Initialize the form, setup time based triggers */
function Initialize() {

deleteTriggers_();

if ((FORM_OPEN_DATE !== “”) &&
((new Date()).getTime() < parseDate_(FORM_OPEN_DATE).getTime())) {
closeForm();
ScriptApp.newTrigger(“openForm”)
.timeBased()
.at(parseDate_(FORM_OPEN_DATE))
.create();
}

if (FORM_CLOSE_DATE !== “”) {
ScriptApp.newTrigger(“closeForm”)
.timeBased()
.at(parseDate_(FORM_CLOSE_DATE))
.create();
}

if (RESPONSE_COUNT !== “”) {
ScriptApp.newTrigger(“checkLimit”)
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
}

}

/* Delete all existing Script Triggers */
function deleteTriggers_() {
var triggers = ScriptApp.getProjectTriggers();
for (var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
}

/* Send a mail to the form owner when the form status changes */
function informUser_(subject) {
var formURL = FormApp.getActiveForm().getPublishedUrl();
MailApp.sendEmail(Session.getActiveUser().getEmail(), subject, formURL);
}

/* Allow Google Form to Accept Responses */
function openForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(true);
informUser_(“Your Google Form is now accepting responses”);
}

/* Close the Google Form, Stop Accepting Reponses */
function closeForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(false);
deleteTriggers_();
informUser_(“Your Google Form is not open at this time”);
}

/* If Total # of Form Responses >= Limit, Close Form */
function checkLimit() {
if (FormApp.getActiveForm().getResponses().length >= RESPONSE_COUNT ) {
closeForm();
}
}

/* Parse the Date for creating Time-Based Triggers */
function parseDate_(d) {
return new Date(d.substr(0,4), d.substr(5,2)-1,
d.substr(8,2), d.substr(11,2), d.substr(14,2));
}