-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGapp-script_2
More file actions
45 lines (34 loc) · 1.08 KB
/
Gapp-script_2
File metadata and controls
45 lines (34 loc) · 1.08 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function doGet(e){
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName(e.parameter["id"]);
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
var lastRow = sheet.getLastRow();
var cell = sheet.getRange('a1');
var col = 0;
var d = new Date();
for (i in headers){
// loop through the headers and if a parameter name matches the header name insert the value
if (headers[i] == "Timestamp")
{
val = d.toDateString() + ", " + d.toLocaleTimeString();
}
else
{
val = e.parameter[headers[i]];
}
// append data to the last row
cell.offset(lastRow, col).setValue(val);
col++;
}
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lastRow = sh.getLastRow();
var lastCol = sh.getLastColumn();
var data = sh.getRange(lastRow, lastCol).getValue();
if(data > 10)
{
var to = "name@gmail.com"; // Target Email ID
var message = "The new data is " + data + " \n" ;
MailApp.sendEmail(to, " alert! ", message);
}
return ContentService.createTextOutput('success');
}