-
Notifications
You must be signed in to change notification settings - Fork 0
/
TempF.gs
47 lines (37 loc) · 1.23 KB
/
TempF.gs
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
46
47
/* Using spreadsheet API */
function doGet(e) {
Logger.log( JSON.stringify(e) ); // view parameters
var result = 'Ok'; // assume success
if (e.parameter == undefined) {
result = 'No Parameters';
}
else {
var id = '16IQP2zjOqVH1qWQJ1IGiygshhNX7mFOuPMxMCBTza-c';
var sheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/16IQP2zjOqVH1qWQJ1IGiygshhNX7mFOuPMxMCBTza-c/edit#gid=530749950').getActiveSheet();
var newRow = sheet.getLastRow();
var rowData = [];
for (var param in e.parameter) {
Logger.log('In for loop, param='+param);
var value = stripQuotes(e.parameter[param]);
switch (param) {
case 'tempfData': //Parameter
rowData[0] = value; //Value in column B
break;
default:
result = "unsupported parameter";
}
}
Logger.log(JSON.stringify(rowData));
// Write new row below
var newRange = sheet.getRange(newRow, 5, 1, rowData.length);
newRange.setValues([rowData]);
}
// Return result of operation
return ContentService.createTextOutput(result);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}