I have a google form and the corresponding results spreadsheet. I have a google apps script on the sheet that is intended activate on form submit. It reads the entry, puts formats the filled in columns into an email, and sends that email out to a specified address. All that works as intended.
However, there is a case statement that is supposed to set the target e-mail address & subject line based on the text in one of the columns. I can't get it to read anything but the default case. The text in the column (the 'campus' column) seems to match the case statements? Anyone have advice? Thanks!
function SendGoogleForm(e) {
if (MailApp.getRemainingDailyQuota() < 1) return;
var s = SpreadsheetApp.getActiveSheet();
var columns = s.getRange(1, 1, 1, s.getLastColumn()).getValues()[0];
var email = "";
var subject = "";
var message = "";
switch (e.namedValues["Campus"]){
case "Lower School":
email = "xxxx@*****.org";
subject = "LS Ticket Created";
message = "Campus column is: " + e.namedValues["Campus"] + "\n";
message += "Case is: Lower School"+"\n";
break;
case "Upper School":
email = "yyyy@*****.org";
subject = "US Ticket Created";
message = "Campus column is: " + e.namedValues["Campus"] + "\n";
message += "Case is: Upper School"+"\n";
break;
case "S*******":
email = "zzzz@*****.org";
subject = "SC Ticket Created";
message = "Campus column is: " + e.namedValues["Campus"] + "\n";
message += "Case is: S*******"+"\n";
break;
default:
email = "xxxx@*****.org";
subject = "General Ticket Created";
message = "Campus column is: " + e.namedValues["Campus"] + "\n";
message += "Case is: Default"+"\n";
break;
}
for (var keys in columns) {
var key = columns[keys];
if (e.namedValues[key] && (e.namedValues[key] !== "")) {
message += key + ' :: ' + e.namedValues[key] + "\n\n";
}
}
MailApp.sendEmail(email, subject, message);
}