I'm trying to set up a basic script that emails on form submission, with the (pie in the sky) goal of creating an email that will send an attached outlook calendar invite. Here is my script.
function onFormSubmit(e) {
var userName = e.values[1];
var userEmail = e.values[2];
var subject = "Form Submitted";
var message = "Thank you, " + userName + " for your submission";
MailApp.sendEmail(userEmail, subject, message)
}
Here's an image of my trigger situation
The error I get is: "TypeError: Cannot read property "0" from undefined."
Here's an image of the Execution transcript
Here's where I've been: Google Scripts for Sheets - onEdit and "source"
I promise I'm not running in the editor - I'm filling out the form and submitting. I know I have to be doing something stupid, but I can't figure out what it is. Thanks for your help.
values
property of the event object sent to a script bound to the Form. If you set up the code to be in a project bound to a spreadsheet, then you can use thevalues
property. If you don't want to use a script bound to a spreadsheet, you'll need to usee.response
which gets a Form response. Apps Script documentation - Form response Then you'll need to get the values out of the Response. – Alan Wells