I have a Google Form attached to a spreadsheet. Everytime the data is submitted via the form into the spreadsheet. Then the spreadsheet should automatically send an email to several individuals but, it's not working.
Here is my code:
function myFunction(row) {
var sheets = SpreadsheetApp.getActiveSpreadsheet();
var sheet = sheets.getSheets()[0]; // Form Responses 1
var columnName = sheet.getRange("A1:S1").getValues();
var dataRange = sheet.getRange(row);
var data = dataRange.getValues();
var responseObj = {};
var carId = "";
for (var i = 2; i < columnName[0].length; i++) {
var key = columnName[0][i];
var value = dateFormat(data[0][i],key);
responseObj[key] = value;
if(key === "Car ID"){
carId = value;
}
}
var htmlBodyLoc = doGet(responseObj);
MailApp.sendEmail({
to: '[email protected],[email protected],[email protected]',
subject:'Car Inspection - ' + outletId + ' ' + new Date(),
htmlBody: htmlBodyLoc,
});
}
I am actually getting an error on this line: var dataRange = sheet.getRange(row);
Thanks.
row
has no value--it isundefined
. So you are not calling your function properly. - tehhowch