Delete Triggers by Handler Name

Re-running an install function without cleanup creates duplicate triggers — and suddenly your sync fires five times. This deletes every project trigger wired to a given handler name.

What you'll need

  • The exact handler function name (string match)
  • Edit access to the project (to manage triggers)

How to use this snippet

function deleteTriggersByHandler(handlerName) { var triggers = ScriptApp.getProjectTriggers(); var removed = 0; for (var i = 0; i < triggers.length; i++) { if (triggers[i].getHandlerFunction() === handlerName) { ScriptApp.deleteTrigger(triggers[i]); removed++; } } return removed; } function reinstallNightly() { deleteTriggersByHandler('runNightlySync'); createDailyTrigger('runNightlySync', 2); }

Tips:

  • Only touches project triggers (getProjectTriggers), not user-owned ones from other accounts.
  • Return value is handy for logging in a setup menu toast.

Happy Coding!

NitroGAS Chrome Extension

Want this snippet handy inside the Apps Script editor? NitroGAS gives you free themes and snippets — plus optional Co-Pilot when you want a boost (1-week, 1-month, or yearly passes — no subscription). Happy Coding!

Get the Extension