Object reference
Trigger
A ScriptApp.Trigger is one installed schedule or event rule owned by the current user in this project. Use ScriptApp.getProjectTriggers() to inspect its handler function or delete it with ScriptApp.deleteTrigger().
ScriptApp.TriggerStart here
Get this object first
List the current user’s installable triggers in this project, then look at the first one. There may be none for this user, 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 the current user’s handler functions and event types
This lists the function name and event type for each installable trigger associated with the current user in this project and does not change any of them.
ScriptApp.TriggerShow example code
function logAllTriggerDetails() {
const triggers = ScriptApp.getProjectTriggers();
triggers.forEach((trigger) => {
Logger.log(trigger.getHandlerFunction() + ' - ' + trigger.getEventType());
});
} Find the current user’s trigger by handler function name
This looks for an installable trigger associated with the current user in this project that runs a chosen function name and reports whether one is installed.
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 the current user’s triggers for one function (this removes triggers)
This deletes every installable trigger associated with the current user in this project whose handler function matches the chosen name. Triggers associated with other users are left alone; the user who installed them must remove their own schedules.
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
Generated runtime and signature facts stay separate from the beginner actions above. Open method details only 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