How to Fix Google Sheets onEdit Trigger Not Firing
In this tutorial, you'll learn about How to Fix Google Sheets onEdit Trigger Not Firing. We cover key concepts, practical examples, and best practices.
The onEdit trigger in Google Sheets runs a script function every time a user edits a cell. When the trigger does not fire, the function name is wrong, the trigger was not installed, or the edit type (like a formula recalculation) is not supported by the trigger.
The Problem
You write an onEdit function but nothing happens when you edit a cell. The script exists in the Apps Script editor but the trigger never runs.
Wrong approach — adding console.log() statements without checking trigger setup.
The Fix
For a simple trigger, the function must be named exactly onEdit:
function onEdit(e) {
var range = e.range;
range.setNote("Edited at " + new Date());
}
Simple triggers run automatically with no setup required, but have limitations:
- Cannot access services that require authorization (like
GmailApp) - Run as the active user
- Limited to 30 seconds execution
For an installable trigger, create it in the Apps Script editor:
1. Open Extensions → Apps Script
2. Triggers (clock icon) → Add Trigger
3. Choose function → On change → Head
4. Save → authorize permissions
Use an installable trigger when you need to access external services or run as a specific user.
Expected output:
Trigger function runs immediately after cell edit
Function receives the event object (e) with range, value, and source
Changes made by the function appear in the sheet
Prevention Tips
- Name simple triggers exactly
onEdit(case-sensitive) — they do not need manual installation - Use installable triggers when your script needs permissions beyond the current sheet
- Check execution logs (Apps Script > Executions) to see if the trigger ran and what errors occurred
- Avoid long-running operations in simple triggers — they have a 30-second limit
- Use
e.rangeto access the edited cell, notSpreadsheetApp.getActiveRange(), for reliable results
Common Mistakes with sheets onedit trigger
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations
These mistakes appear frequently in real-world GOOGLE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Related: DodaTech's Trigger Health Dashboard monitors all active triggers, logs execution times, and alerts when triggers fail or exceed time limits. Use with DodaZIP for backup before trigger deployment.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro