Skip to content

Multi-Day Booking

little trigger-installer

/* * Rebuild all installable triggers for this spreadsheet project. * Safe to run manually from Apps Script. / function createInstallableTriggers() { const ss = SpreadsheetApp.getActive();

// Remove existing triggers for this project first, // so we don't end up with duplicates. const triggers = ScriptApp.getProjectTriggers(); for (const trigger of triggers) { ScriptApp.deleteTrigger(trigger); }

// Spreadsheet on edit trigger ScriptApp.newTrigger('onApprovalEdit') .forSpreadsheet(ss) .onEdit() .create();

// Form submit trigger ScriptApp.newTrigger('setPendingOnFormSubmit') .forSpreadsheet(ss) .onFormSubmit() .create();

Logger.log('Installable triggers recreated successfully.'); }

Checker Function

/* * Lists current project triggers in the log. / function listProjectTriggers() { const triggers = ScriptApp.getProjectTriggers();

if (triggers.length === 0) { Logger.log('No project triggers found.'); return; }

triggers.forEach((t, i) => { Logger.log( '%s) Function: %s | Event: %s | Source: %s', i + 1, t.getHandlerFunction(), t.getEventType(), t.getTriggerSource() ); }); }