1

trying to find out where i'm going wrong. I'm not a coder, but am re-using code from another google sheet I've used.

I'm trying to trigger an email being sent when a form is submitted that populates this google sheet.

Here is the public sheet: https://docs.google.com/spreadsheets/d/1oV8bwS_o7O-Wu5LXoP-0e9M71NpbQy-a0ViTSZhXJPA/edit?usp=sharing

Here is the code:

function FormSubmit(formData) {
// Load the sheets for processing
var responseSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Master Editing Sheet");
var supData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Support Data");
// Create and send the Email 
// Description is used to make the email
var description = supData.getRange(2,1).getValue();
var name = formData.namedValues["Prospects' Names"];

var timestamp = formData.namedValues["Timestamp"];

var to = "andrew.appel@gmail.com";
var subject = "New Prospect Submitted: " + name;
var message = "New Prospect | Submitted by | Initial Contact | Initial Notes: " + "\n" + "\n";
message += description + "\n" + "\n";
message += "The Master Recruitment Spreadsheet can be viewed by clicking on  the following link" + "\n";
message += "https://tinyurl.com/recruitmaster"
MailApp.sendEmail(to, subject, message);
}

Thank you so much!! Andrew

1 Answers1

0

The data that you are passing into the function is not valid so you can't call a property of it. It is basically like trying to call undefined.namedValues

You might want to check where the function is called.

SBoys3.com
  • 424
  • 3
  • 12
  • Hi there, unfortunately, I'm such a newbie that I don't know how to do that...is it because it only gets defined when a form is submitted? I'm testing it in the Script editor – Andrew Appel Nov 12 '15 at 22:51
  • Hi, I just tested the working code in a different spreadsheet and it gets teh same error in the debugger, but works with the forms being submitted. So, I'm wondering why this code doesn't send the email, like the other does. – Andrew Appel Nov 12 '15 at 22:54