Google Sheets · Automation bounded introductory track · Intermediate
Understand script authorization, triggers and quotas
Separate event, authorization and quota failures using a bounded edit-marker fixture and explicit lifecycle checks.
Documentation-reviewed author candidate; no native application execution. · Editorial standards
Quick answer
Diagnose an automation by separating three questions: did the expected event occur, which account and permissions apply, and did a runtime or quota limit stop execution? A simple onEdit(e) is not a scheduled job, and clicking Run in the editor does not supply its normal edit event.
Choose a deliberately limited test
Use a private Google Sheets file on a computer. This exercise is for a user-owned bound script, with no email, external services, deployment, credentials or installable trigger creation. If you need basic editor setup or breakpoint help, use the separate Apps Script debugging exercise.
Create a tab named EventLab. Put State in A1, Open in B2, Marker in C1, and Reset in C2. C2 is a disposable output. The intended result is a harmless marker when a person edits exactly B2 on this tab. Changes elsewhere should not update it.
In the file’s bound Apps Script project, use this small handler. Do not add it to a production project that already has an onEdit function; use the new practice file to avoid collisions.
/** @OnlyCurrentDoc */
function onEdit(e) {
if (!e || !e.range) return;
const range = e.range;
const sheet = range.getSheet();
if (sheet.getName() !== 'EventLab') return;
if (range.getA1Notation() !== 'B2') return;
sheet.getRange('C2').setValue('Observed B2 edit');
}
Save the project. This reserved function is a simple trigger; there is no installable-trigger setup step. It uses the event’s own sheet, not whichever tab happens to be active later. It tests the exact edited range, so a multi-cell paste covering B2:C2 is intentionally not accepted as a single B2 edit.
Run a small event matrix
- In the sheet, type Done into B2. C2 should become Observed B2 edit.
- Manually reset C2 to Reset. That edit is outside B2, so it should stay Reset.
- Change A2 to Control. C2 should still be Reset.
- Change B2 back to Open. C2 should again show the marker.
- Reset C2, then choose onEdit and click Run in the script editor. With no event object, the guard returns without writing. C2 should remain Reset.
This matrix tells you more than a single successful marker. It checks the positive path, two irrelevant-cell controls, a changed input and the missing-event case. The marker is not an audit trail: repeated edits overwrite the same cell, and it does not establish who made a change.
A script’s setValue() call or an API update does not cause the spreadsheet’s onEdit event. Formula recalculation is not the same as a person’s cell edit either. Therefore, do not use this example to promise alerts for every upstream data change. The handler’s own C2 write will not recursively trigger itself through a new user edit.
Understand the authorization boundary
Simple triggers can modify their bound file but cannot call services that require authorization or open arbitrary other files. They also have a 30-second execution limit. This example needs neither a permission-broadening workaround nor a service that requires interactive consent.
A manually run function and an installable trigger are different execution contexts. Installable triggers run as their creator, not simply as whichever collaborator changed the sheet. Adding a new authorized service to a script may introduce a new consent request. Review that exact access and ownership before proceeding; do not authorize unrelated scopes to silence an error.
The @OnlyCurrentDoc annotation limits relevant document scope for the supported services. It does not authorize the script to ignore organization policy, and it does not make a third-party script trustworthy. If a blocked-app warning appears during a different workflow, stop and investigate the specific script and account instead of bypassing it.
Diagnose a real failure without causing one
Do not intentionally exhaust quotas. Instead, inspect a failing execution through the Apps Script editor’s Executions panel and record the function, time, status and error. Distinguish a short burst-rate limit from a daily quota and from an execution that ran too long. The remedy for one is not necessarily useful for another.
Google’s quota limits vary by account class and can change. Daily quotas are generally per user and reset 24 hours after the first request, not automatically at local midnight. Check the official current table for the service actually named in the error. An unrelated email quota does not diagnose this current-file marker.
Repeated immediate retries can worsen rate-limit problems. For a real automation, first inspect unnecessary calls, overlapping runs and repeated work. This tiny example deliberately performs only a few checks and one write. It is not a template for high-volume auditing: simple onEdit queues only a small number of events, so rapid bursts are not a reliable event archive.
Inspect lifecycle before removing anything
If you are diagnosing an existing installable automation, inspect its actual owner and trigger configuration. At the Apps Script dashboard, My Triggers lists triggers associated with your account; do not assume it shows another person’s triggers. Removing a trigger is a separate decision from repairing code or revoking account access.
For a disposable trigger you intentionally created elsewhere and no longer need, the documented removal route is its More > Delete trigger action. Identify it precisely first; this tutorial creates no such trigger. Do not delete every trigger in a shared project to stop one error message.
For this simple-handler exercise, remove or rename the practice onEdit function, save, reset C2 and edit B2 once more. The marker should no longer be written. Retain the code in your own notes if you want to restore it later. Reopen the file and repeat that final state check; downloading a workbook does not carry this trigger lifecycle into Excel.
No trigger, authorization grant or quota test was executed during authoring.
Official references
References: simple triggers, installable triggers, authorization, and quotas.
API references for the event guard: Range methods and Sheet methods.