Last active
June 14, 2020 09:40
-
-
Save sirateek/d6d30d9323004f086369f60c3e37ac88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple Trigger (normal onEdit() Function) have the restriction which can't be used to call any functions | |
// that required the authorization. So use Installable Trigger instead. | |
// Warning:! Set Trigger for one time only otherwise you will have duplicate triggers!. | |
// Note: createSpreadsheetOpenTrigger will not return anything if success. | |
function createSpreadsheetOpenTrigger() { | |
var ss = SpreadsheetApp.getActive(); | |
// Set Installable Trigger. | |
ScriptApp.newTrigger('specialOnEdit').forSpreadsheet(ss).onEdit().create(); | |
} | |
function specialOnEdit(e) { | |
var range = e.range; | |
range.setNote(JSON.stringify(e)); | |
sendToLineNotify("(" + range.columnStart + "," + range.rowStart + ") > " + e.value); | |
} | |
// Normal UrlFetch Functions. | |
function sendToLineNotify(text) | |
{ | |
var bodyPayload = { | |
"message": text, | |
}; | |
var lineNotifyToken = ""; | |
var requestData = { | |
"method": "post", | |
"headers": { | |
"Authorization": "Bearer " + lineNotifyToken | |
}, | |
"contentType": "application/x-www-form-urlencoded", | |
"payload" : bodyPayload | |
}; | |
UrlFetchApp.fetch("https://notify-api.line.me/api/notify", requestData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment