Page Summary
-
Apps Script can run a function automatically using simple or installable triggers when a specific event occurs.
-
When a trigger fires, an event object (
e) containing contextual information is passed to the function as an argument. -
This page details the fields within the event object for various trigger types across different Google services like Sheets, Docs, Slides, Forms, Calendar, and Workspace add-ons.
-
Events produced by installable triggers include a
triggerUidto identify the specific trigger. -
Calendar triggers indicate that a sync operation is needed, not which specific event changed.
Simple triggers and
installable triggers let
Google Apps Script run a function automatically if a certain event
occurs. When a trigger fires, Apps Script passes the function an
event object as an argument, typically e. The event object contains
information about the context that caused the trigger to fire. For example, the
following sample code shows a simple onEdit(e) trigger for a Google Sheets
script that uses the event object to determine which cell was edited.
function onEdit(e){
// Set a comment on the edited cell to indicate when it was changed.
var range = e.range;
range.setNote('Last modified: ' + new Date());
}
This page describes the fields in the event object for different types of triggers.
Events produced by installable triggers contain a triggerUid identifying the
trigger that produced the event. This helps scripts that have multiple
installable triggers.
Google Sheets events
The various Google Sheets-specific triggers let scripts respond to a user's actions in a spreadsheet.
Open(simple and installable) |
|
|---|---|
authMode |
A value from the LIMITED |
source |
A Spreadsheet |
triggerUid |
ID of trigger that produced this event (installable triggers only). 4034124084959907503 |
user |
A amin@example.com |
Change(installable) |
|
|---|---|
authMode |
A value from the FULL |
changeType |
The type of change ( INSERT_ROW |
source |
A
Spreadsheet |
triggerUid |
ID of trigger that produced this event. 4034124084959907503 |
user |
A amin@example.com |
Edit(simple and installable) |
|
|---|---|
authMode |
A value from the LIMITED |