sheets.org
Google Sheets

Automate Your Reports: Google Apps Script Triggers Explained

A macro you run by hand saves minutes. A trigger saves the remembering: it runs your function every Monday at 8am, or every time a form response lands, with nobody at the keyboard. Triggers are the difference between a script and an automation. This post assumes you can write a basic Apps Script function — if not, start with our first-macro guide.

The two kinds of triggers

  • Simple triggers — functions with magic names like onOpen(e) and onEdit(e). Zero setup, but limited: they cannot do anything that needs authorization, like sending email.
  • Installable triggers — configured under the clock icon (Triggers) in the Apps Script editor. These can be time-driven (hourly, daily, weekly, monthly), fire on edits and form submissions, and run with your full permissions.

The classic: a weekly status email

This reads a summary range and mails it every week:

function weeklyReport() {
  const sheet = SpreadsheetApp.getActive().getSheetByName('Summary');
  const rows = sheet.getRange('A2:C10').getValues();
  const body = rows
    .filter(r => r[0] !== '')
    .map(r => r[0] + ': ' + r[1] + ' (' + r[2] + ')')
    .join('\n');
  MailApp.sendEmail('you@example.com', 'Weekly Report', body);
}

Then: clock icon > Add Trigger > choose weeklyReport, event source Time-driven, type Week timer, Monday 8–9am. Authorize once. Done — it now sends itself.

onEdit: react to changes

An installable on-edit trigger can validate, timestamp, or notify. A pattern that shows the shape — auto-timestamp column B when someone edits column A:

function stampEdit(e) {
  const range = e.range;
  if (range.getColumn() === 1 && range.getRow() > 1) {
    range.offset(0, 1).setValue(new Date());
  }
}

The e event object tells you what changed — always check it first and return early, because this function runs on every edit.

Rules that keep triggers reliable

  • Time-driven triggers are approximate. "8–9am" means sometime in that window, not 8:00 sharp.
  • Quotas exist. Free accounts get 90 minutes of total trigger runtime per day and a daily email cap — generous for reports, relevant for loops gone wrong.
  • Failures are silent unless you look. The editor’s Executions panel shows every run and error; set trigger failure notifications to email you.
  • Make functions idempotent. Design a run so that running twice does no harm — write to a dated row rather than appending blindly, and your occasional double-fire becomes a non-event.
  • Triggers run as their creator — your quotas, your permissions, even when others use the sheet.

Where to go next

Chain the pieces: a Form feeds a Sheet, an on-form-submit trigger validates and formats the new row, and a Monday timer mails the pivot summary to the team. Each piece is ten lines of code, and together they retire an entire recurring chore. That compounding is the whole appeal of Apps Script.