Google Sheets automation with Apps Script: scheduled reports and alerts

by fidji Gemini English ~597 tokens
Public excerpt Locked
Spec confirmed first, then a complete .gs file: CONFIG object, getValues / setValues in batch, columns looked up by header, LockService, try / catch to a Log tab, rerun-safe week key, DRY_RUN flag, createTriggers() and a test plan on a copy of the sheet…

About this prompt

Automates a recurring Google Sheets chore (weekly consolidation, summary email, threshold alerts) with a robust Apps Script: configuration in one place, batch reads and writes, headers found by name, lock against overlapping runs, a log tab, a dry-run mode and a time-driven trigger. Designed for Gemini and Google Workspace users; totals are always computed by the script, never by the AI.

Example output

Provided by the author
```javascript /** @OnlyCurrentDoc */ const CONFIG = { sourceTabs: ['North', 'South', 'East', 'West'], targetTab: 'Consolidated', logTab: 'Log', headers: { date: 'Date', region: 'Region', amount: 'Net amount' }, weeklyTarget: { North: 12000, South: 9000, East: 9000, West: 7500 }, recipients: ['ops-managers@example.com'], DRY_RUN: true, }; function weeklyReport() { const lock = LockService.getScriptLock(); if (!lock.tryLock(30000)) return log_('weeklyReport', 'Another run in progress, skipped'); try { const weekKey = getLastWeekKey_(); // e.g. "2025-W44" if (alreadyProcessed_(weekKey)) return log_('weeklyReport', weekKey + ' already done'); const rows = collectRows_(weekKey); // batch getValues, columns by header const totals = totalsByRegion_(rows); … } catch (e) { log_('weeklyReport', 'ERROR ' + e.message); MailApp.sendEmail(Session.getEffectiveUser().getEmail(), 'Weekly report failed', e.stack); } finally { lock.releaseLock(); } } ``` Test 3 — duplicate run: the second run logs "2025-W44 already done" and appends nothing…

Details

Model
Gemini
Prompt language
English
Who it's for
Operations, finance and marketing staff who repeat the same Google Sheets task every week
Length
~597 tokens (estimate)
Delivered as
Prompt text, shown online after purchase

Reviews

Buyers only

No reviews yet. Only buyers of this prompt can leave one.

Report this prompt