/**
* Delete installable triggers by name
* Since multiple triggers can target the same handler function, this script caters for single and multiple matches.
*/
function myfunction() {
const triggerName = "myfunctionName"; // Configure the function name of the installable triggers to be deleted.
const triggers = getProjectTriggersByName(triggerName); // Retrieve all triggers that target the specified function name.
for (let i = 0; i < triggers.length; ++i) { // Loop through each matched trigger.
ScriptApp.deleteTrigger(triggers[i]); // Delete the matched trigger.
}
}
/**
* Returns an array of project triggers that call a specified function.
* @param {string} name - The name of the handler function to match
* @return {GoogleAppsScript.Script.Trigger[]} Array of matching triggers
*/
function getProjectTriggersByName(name) {
return ScriptApp.getProjectTriggers().filter(trigger => trigger.getHandlerFunction() === name); // Return triggers that match the handler name.
}