-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigger.gs
33 lines (28 loc) · 884 Bytes
/
trigger.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
function startTracking() {
ScriptApp.newTrigger("processTransactionEmails")
.timeBased()
.everyMinutes(1).create();
return "Started tracking successfully!";
}
function stopTracking() {
var triggers = ScriptApp.getProjectTriggers();
for (var i = 0; i < triggers.length; i++) {
if (triggers[i].getHandlerFunction() == "processTransactionEmails") {
ScriptApp.deleteTrigger(triggers[i]);
return "Stopped tracking successfully";
}
}
return "Error in stopping tracking!"
}
function getTrackingStatus() {
var triggerName = "processTransactionEmails";
var triggers = ScriptApp.getProjectTriggers();
var isTrackingStarted = false;
for (var i = 0; i < triggers.length; i++) {
if (triggers[i].getHandlerFunction() === triggerName) {
isTrackingStarted = true;
break;
}
}
return isTrackingStarted ? "STARTED" : "STOPPED";
}