title: onSubmit event not working msg: TypeError: Cannot read property "values" from undefined
body: <p>I have a google form contain only one question 
  <a href="https://i.stack.imgur.com/6J5bg.png" rel="nofollow noreferrer">form layout</a></p>
  
  <p>and I would like to update the confirmation message in the onSubmit event. 
  Here is my code, </p>
  
  <pre><code>function onsubmit1(event){  
    var activeform = FormApp.getActiveForm();
    activeform.setConfirmationMessage("Thank you "+ event.values[0]);
  }
  </code></pre>
  
  <p>My deployment step is </p>
  
  <ol>
  <li>save the code</li>
  <li>Add Trigger (function to run: onsubmit1(), Choose which deployment should run: HEAD, Select event source: from FORM, Select event type: on form submit, Failure notification settings: notify me daily)</li>
  <li>Run onsubmit1</li>
  </ol>
  
  <p>and then<br>
  the error message shown </p>
  
  <blockquote>
    <p>TypeError: Cannot read property "values" from undefined. (line 3, file "onsubmit") </p>
  </blockquote>
  
  <p>and the deployment is failed. </p>
  
  <p><img src="https://i.stack.imgur.com/IXlFH.png" alt="deployment error message"></p>
  
  <p>How can I retrieve the value from the current response?</p>
  
  <p>//Update
  I have modified the code to </p>
  
  <pre><code>function onSubmit(e){
    var namevar = e.response.getItemResponses()[0].getResponse();
    var form = FormApp.getActiveForm();
    form.setConfirmationMessage("Thank you"+namevar);
  }
  </code></pre>
  
  <p>The function can be run with event captured.
  However, as the other mentioned, confirmation message CANNOT be set in this way as namevar returned the response of last submission. </p>
  
  <p>Explanation can be found in 
  <a href="https://stackoverflow.com/questions/22738404/how-to-set-confirmation-message-based-on-form-responses-in-google-forms-using-ap">how to set Confirmation Message based on form Responses in google forms using Apps Script?</a> </p>