Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

"Thank you for supporting the MIT Shakespeare Ensemble
All performances are in La <La Sala de Puerto Rico (W20-202) on the second floor of the MIT Stratton Student Center (84 Massachusetts Ave) / Kresge Little Theater (W16-035) on MIT's campus (48 Massachusetts Ave)>.

Tickets prices are:
    $5 for MIT, Harvard, and Wellesley students
    $9 for MIT affiliates and other students
    $12 for general public

Payment for tickets is cash only and will be handled at the door on the day of the performance.

Reservations close for a show an hour before the show starts. You can still get tickets at the door!

A reservation will guarantee you a seat admission as long as you arrive 15 minutes before the performance to claim it. Other than that, our performances Specific seating and other ticket sales are first come, first serve. We may need to give your ticket away if you arrive late.

<Any content warnings, the length of the show, etc.>"

The confirmation page should say something like the following:

...

function SendConfirmationMail(e) {    // e is an event object that is defined by the event of form submission. Contains submission info. 
     var ss, bcc, sendername, subject, headers, ptest;
     var message, value, textbody, sendto;
     bcc = "ensemble-tickets@mit.edu";
     sendername = "MIT Shakespeare Ensemble";
     subject = "EXAMPLE Ticket Reservation Confirmation";
     message = "We have received your ticket reservation.<br>Thank you!<br>Please arrive to pick up your reservation at least 15 minutes before performance time.<br>The performance will be in La Sala de Puerto Rico (W20-202), on the second floor of the MIT Stratton Student Center at 84 Massachusetts Ave.<br><br>";
     ss = SpreadsheetApp.getActiveSheet();
     headers = ss.getRange(1, 1, 1, ss.getLastColumn()).getValues()[0];                      // Creates an array of the column headers.
 
     ptest = ss.getRange(ss.getLastRow(), 1, 1, ss.getLastColumn()).getValues()[0];          // Gets the last row from the spreadsheet. Will be used instead of e.
     Logger.log(headers);                                                                    // Adds headers to log. Note that the log is not actually used for anything :P
     Logger.log(ptest);
//     Logger.log(e);   // Adds event object in its entirety to the log.
//     sendto = e.namedValues['Email Address'][0];   // Pulls the email address from the event object.
  sendto = ptest[headers.indexOf('Email Address:')]                                        // Pulls the email address by finding the index within headers. Make sure the name of the header here exactly matches what it is on the form or it won't work!
     for (var i in headers) {                                                                // For every key in headers
//       value = e.namedValues[headers[i]][0].toString();   // Gets the value corresponding to a specific header from the event object. Makes it a string. This line is hard for a human to read.
       value = ptest[i].toString()                                                           // Gets the value corresponding to a specific header.
       Logger.log(value);                                                                    // Adds this value (such as "Peter" for "First Name") to the log.
       if ((i !== "0") && (value !== "")) {                                                  // If this is not the Timestamp && the form field was not left blank.
           message += headers[i] + ' :: ' + value + "<br>";                                  // Add the header, a little space, the form input value, and then a line break.
       }
     }
     textbody = message.replace("<br>", "\n");                                               // This changes the HTML line break character to the text interpreter line space character.
     GmailApp.sendEmail(sendto, subject, textbody,                                           // Sends an email to the person who filled out the form, with a previously defined subject and body.
                        {bcc: bcc, name: sendername, htmlBody: message, replyTo: bcc});      // This is an optional field. Adds bcc to us and changes the name of the sender. htmlBody makes it so that devices capable of rendering HTML will render that instead. replyTo sets the default reply-to address, us.
}

...

The above code essentially takes an event (that will be the form submission) and sends an email confirmation based on the information in the form. However, the thing that triggers the script (the form submission) has not yet been defined. While in the script editor, go to the "ResourcesEdit" menu and select "Current Projectproject's Triggerstriggers". This should open a window that says "No triggers set up. Click here to add one now". Click on thatresults" in the middle. Click on the "+ Add Trigger" button in the lower right hand corner, and create a trigger : Run: SendConfirmationMail; Events: From spreadsheet; On form submit.with the following properties:

  • Under "Choose which function to run" select "SendConfirmationMail" (this should already be selected by default, but double-check just to be sure)
  • Under "Choose which deployment should run" select "Head" (again, this should be selected by default)
  • Under "Select event source" select "From spreadsheet" (again, this should be selected by default)
  • Under "Select event type" select "On form submit"
  • Under "Failure notification settings" select "Notify me immediately"

Leave all other fields the same.

Press "Save," Press save, then grant the script whatever access to the Ensemble Account that it asks for. Now the trigger should be set up, even if your browser tells you that the app is unverified and potentially unsafe.

Update ensemble-tickets@mit.edu

...

Embedding the Form in the Website

Have the webmaster or an officer or anyone on ensemble-webmaster@mit.edu do the following for you.

In the google Google form, click "Send Form", then press "Embed" to get the html. The height and width can be adjusted later, so don't worry about that.

Now open the Ensemble Locker, and go to web_scripts > tickets > index.php. Under the comment "<!-- EMBED LINK TO GOOGLE FORM BELOW THIS -->", past paste the html from Google forms. Be sure to delete the embedding html from the previous show reservations. Set the width to 84% and the height to 1250px (or whatever looks good).

...