Object reference
Trigger
A ScriptApp.Trigger is one installed schedule or event rule in this project. ScriptApp.getProjectTriggers() returns only the installable triggers that belong to you, the user running the script. Use it to see which function a trigger runs, or delete a trigger with ScriptApp.deleteTrigger(). Other users must delete their own triggers.
ScriptApp.TriggerStart here
Get this object first
List your installable triggers in this project, then look at the first one. You may have none, so check the length first.
function showFirstTriggerHandler() {
const triggers = ScriptApp.getProjectTriggers();
if (!triggers.length) {
Logger.log('No installable triggers are associated with the current user in this project.');
return;
}
Logger.log(triggers[0].getHandlerFunction());
} Then use it
Common actions
Choose an action, then open its example only when you need the code.
List your handler functions and event types
Logs the function name and event type of each of your triggers.
ScriptApp.TriggerShow example code
function logAllTriggerDetails() {
const triggers = ScriptApp.getProjectTriggers();
triggers.forEach((trigger) => {
Logger.log(trigger.getHandlerFunction() + ' - ' + trigger.getEventType());
});
} Find your trigger by handler function name
Looks for one of your triggers that runs the chosen function and logs whether it found one.
ScriptApp.TriggerShow example code
function findTriggerForFunction() {
const functionName = 'sendWeeklySummary';
const match = ScriptApp.getProjectTriggers().find((trigger) => {
return trigger.getHandlerFunction() === functionName;
});
Logger.log(match ? 'Found a current-user trigger for ' + functionName : 'No current-user trigger found for ' + functionName);
} Delete your triggers for one function (this removes triggers)
Deletes each of your triggers that runs the chosen function. Triggers that belong to other users are not deleted.
ScriptApp.TriggerShow example code
function deleteTriggersForFunction() {
const functionName = 'sendWeeklySummary';
const triggers = ScriptApp.getProjectTriggers();
let deletedCount = 0;
triggers.forEach((trigger) => {
if (trigger.getHandlerFunction() === functionName) {
ScriptApp.deleteTrigger(trigger);
deletedCount += 1;
}
});
Logger.log('Deleted ' + deletedCount + ' current-user trigger(s) for ' + functionName);
} Technical reference
Exact names and signatures
Open method details when you need them.
At a glance
- Service
- ScriptApp
- Reference symbol
ScriptApp.Trigger- Object
Trigger- Runtime
- From signature data
Methods and signatures
Browse 5 methods
getEventType
- getEventType(): ScriptApp.EventType
getHandlerFunction
- getHandlerFunction(): string
getTriggerSource
- getTriggerSource(): ScriptApp.TriggerSource
getTriggerSourceId
- getTriggerSourceId(): string
getUniqueId
- getUniqueId(): string
Need the whole workflow?
Return to a task guide
Task guides cover setup, permissions, expected results, and troubleshooting as well as object methods.
Browse Triggers tasks