-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComments Handler.js
More file actions
25 lines (23 loc) · 1.06 KB
/
Comments Handler.js
File metadata and controls
25 lines (23 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
* This function handles comments submitted through
* forms and alerts boss.
* @Trigger: Form-submit.
* Author: Abraham Vargas
*/
function commentsHandler() {
var ss = SpreadsheetApp.openById("1xoED6K6FSYiII-Mg1qiyzt-e-5vpto6ZxT-k5pyCNKc");
var sheet = ss.getSheets()[0]; // ”0″ is the first sheet
var lastRow = sheet.getLastRow(); // Number of rows to process
var comCol = sheet.getLastColumn()-1; // Comments column
var dataRange = sheet.getRange(lastRow, comCol); // last row, Comments column
// Fetch values for each row in the Range.
var data = dataRange.getValues();
// Write email if comment exists.
if(String(data).length != 0){
var emailAddress = "[email protected]";
var message = "A comment was submitted in the equipment checkout database."; // pulls the topic from the sixth column for the email message Abe edit string
var subject = "Comment Submitted"; // makes the subject what is in quotes
MailApp.sendEmail(emailAddress, subject, message); // send email to Boss.
}
descendOrder(); // Sorts sheet on form submit
}