Dashboard Mode - Triggers (onEdit, onOpen)
Dashboard Goal
This dashboard shows how to use Google Sheets triggers onEdit and onOpen to automate tasks. It answers: How can we automatically update or notify when data changes or when the sheet opens?
This dashboard shows how to use Google Sheets triggers onEdit and onOpen to automate tasks. It answers: How can we automatically update or notify when data changes or when the sheet opens?
| Task | Status | Last Updated |
|---|---|---|
| Prepare Report | Pending | 2024-06-01 09:00 |
| Send Email | Done | 2024-06-01 08:30 |
| Update Website | Pending | 2024-05-31 17:00 |
| Backup Data | Done | 2024-06-01 07:45 |
| Team Meeting | Scheduled | 2024-06-02 10:00 |
=COUNTIF(B2:B6, "Pending")onOpen trigger script.onEdit trigger script.function onOpen() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Dashboard'); sheet.getRange('E1').setValue(new Date()); }function onEdit(e) { const logSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('EditLog'); const range = e.range; const oldValue = e.oldValue || 'N/A'; const newValue = range.getValue(); logSheet.appendRow([new Date(), range.getA1Notation(), oldValue, newValue]); }+----------------------+--------------------+ | Pending Tasks: [ 2 ] | Last Open: [time] | +----------------------+--------------------+ | Edit Log Table | | Timestamp | Cell | Old Value | New Value | |-------------|------|-----------|--------------| | 2024-06-01 | B3 | Pending | Done | | ... | ... | ... | ... | +---------------------------------------------+
When you open the sheet, the onOpen trigger runs and updates the Last Sheet Open Time KPI automatically.
When you edit any cell, the onEdit trigger runs and adds a new row to the Edit Log Table with details about the change.
The Pending Tasks Count updates automatically if you change any task status in the data table.
Try this: Edit the status of a task from "Pending" to "Done".
Question: Which components update?