简体   繁体   中英

TypeError: Cannot read property “namedValues” from undefined. (line 9, file “Code”)

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM