-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.gs
58 lines (49 loc) · 1.42 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
58
var POST_URL = "WEBHOOKURL"
function onEdit(event){
var sheet_name = event.range.getSheet().getName();
var rangeNotation = event.range.getA1Notation();
var oldValue = event.oldValue;
var value = event.value;
var items = [];
if (value == undefined && oldValue == undefined){
if (rangeNotation.includes(':')){
reason = "Multiple Cells edited";
}
else{
reason = "Cell value deleted";
}
}
else{
if (oldValue == undefined){
oldValue = "Empty cell";
}
if (value == undefined){
value = "Empty cell";
}
reason = oldValue + " -> " + value
}
items.push({
"name": "An edit was made",
"value": "Edited sheet: "+ sheet_name +"\nEdited range: " + rangeNotation + "\nEdit made: "+ reason,
"inline": false
});
var date = Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "EEE, d MMM yyyy HH:mm:ss Z")
var options = {
"method": "post",
"headers": {
"Content-Type": "application/json",
},
"payload": JSON.stringify({
"content": "",
"embeds": [{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"color": 33023,
"fields": items,
"footer": {
"text": "Timestamp (UTC): "+date
}
}]
})
};
UrlFetchApp.fetch(POST_URL, options);
}