1

I am the new coordinator of a high school theatre awards program. I have created an evaluation form for the judges to fill out after they have seen their show. They would like to have a copy of their completed form emailed to them after they submit. The only solution I have found requires them to have an account under our domain name. I do not want the respondents to be able to access and edit the original form but I would like them to be able to get a copy of the form they submitted. Is there any way to do this?

3

You will need to use Google Apps Script and to use the old Google Forms as the new one doesn't include yet a way to add the following script.

To add the script,

  1. Open the form in the form editor.
  2. Go to Tools > Script Editor.
  3. Paste the below code.
  4. Save the project and give a name to it.
  5. Run once time to authorize it.

Note: The original code included a line to add the link to edit the response. That line was converted to a comment to meet the requirements stated in the question.

// Adaptation from http://securitasdato.blogspot.mx/2014/11/sending-confirmation-emails-from-google.html

function setup() {

  /* First, delete all previous triggers */
  var triggers = ScriptApp.getProjectTriggers();

  for (var i in triggers) {
    ScriptApp.deleteTrigger(triggers[i]);
  }

  /* Then add a trigger to send an email on form submit */
  ScriptApp.newTrigger("sendConfirmationEmail")
  .forForm(FormApp.getActiveForm())
  .onFormSubmit()
  .create();
}

function sendConfirmationEmail(e) {
  // e is a Form Event object - see https://developers.google.com/apps-script/guides/triggers/events#google_forms_events

  // Edit this to set the subject line for the sent email
  var subject = "Registration Successful";

  // This will show up as the sender's name
  var sendername = "Your Name Goes Here";

  // This is the body of the registration confirmation message
  var message = "Thank you for registering.<br>We will be in touch.<br><br>";
  message += "Your form responses were:<br><br>";

  // response is a FormResponse - see https://developers.google.com/apps-script/reference/forms/form-response
  var response = e.response;

  var textbody, sendTo, bcc;

  // Get the script owner's email address, in order to bcc: them
  bcc = Session.getActiveUser().getEmail();

  // Now loop around, getting the item responses and writing them into the email message
  var itemResponses = response.getItemResponses();
  for (var i = 0; i < itemResponses.length; i++) {
    var itemResponse = itemResponses[i];
    message += itemResponse.getItem().getTitle() +": " + itemResponse.getResponse() + "<br>";
    // If this field is the email address, then use it to fill in the sendTo variable
    // (Optional) Check that your form item is named "Email Address" or edit to match
    if (itemResponse.getItem().getTitle() == "Email Address") {
      sendTo = itemResponse.getResponse();
    }else{
      // If the form don't ask the respondent email address use the following one
      sendTo = 'sendconfirmationemail@googlegroups.com'; //replace this email address by your own default email address.
    }
  }
 // The following line was commented in order to avoid to include the link to edit the response
  // message += "<br>If you wish to edit your response, please click on <a href="\""" +="" response.geteditresponseurl()="" "\"="">this link</a>.";
  message += "<br><br>";
  textbody = message.replace("<br>", "\n");

  GmailApp.sendEmail(sendTo, subject, textbody,
                       {bcc: bcc, name: sendername, htmlBody: message});
}

Reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.