I have a Google sheet connected to a Google form that is set up to send an email to the respondent; this works fine. I have created a column that isn't from the Google Form that is populated with a unique value. "Case 002376" this is made with an array formula. How do a I obtain the last value submitted in this column AI (34) to add as the subject in an email?
=arrayformula( if( len(A2:A), "case " & text(row(A2:A) - row(A2) + 2, "000") & RIGHT(VALUE(A2:A), 3), iferror(1/0) ) )
function onFormSubmit(e) {
SpreadsheetApp.flush();
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getRange(sheet.getLastRow(), 1, 1, 34);
var data = dataRange.getValues();
var row = data[0];
var emailAddress = e.values[27]; // Column AB of last row
var message = "Your report has been received.";
var subject = e.values[34]; // Column AI (data verification cell)
of last row
MailApp.sendEmail(emailAddress, subject, message);
}
The email i receive says undefined. When i use e.values it works for other columns that pre exist from the Google Form, just not the one i created.