Click here to see your recently viewed pages and most viewed pages.
Hide
Apps Script

Event Objects

Simple triggers and installable triggers let 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 called e. The event object contains information about the context that caused the trigger to fire. For example, the sample code below 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 details the fields in the event object for different types of triggers.

Google Sheets events

The various Google Sheets-specific triggers let scripts respond to a user's actions in a spreadsheet.

Event Type Field Example Notes
Open
(simple and installable)
e.authMode LIMITED A value from the ScriptApp.AuthMode enum
e.source Spreadsheet A Spreadsheet object, representing the Google Sheets file to which the script is bound
e.user amin@example.com A User object, representing the owner of the spreadsheet (only available in simple triggers, and only if the current user is allowed to know the owner's email address, depending on a complex set of security restrictions)
Change (installable) e.authMode FULL A value from the ScriptApp.AuthMode enum
e.changeType INSERT_ROW The type of change (EDIT, INSERT_ROW, INSERT_COLUMN, REMOVE_ROW, REMOVE_COLUMN, INSERT_GRID, REMOVE_GRID, or OTHER)
e.user amin@example.com A User object, representing the owner of the spreadsheet (only available in simple triggers, and only if the current user is allowed to know the owner's email address, depending on a complex set of security restrictions)
Edit
(simple and installable)
e.authMode LIMITED A value from the ScriptApp.AuthMode enum
e.user amin@example.com A User object, representing the owner of the spreadsheet (only available in simple triggers, and only if the current user is allowed to know the owner's email address, depending on a complex set of security restrictions)
e.source Spreadsheet A Spreadsheet object, representing the Google Sheets file to which the script is bound
e.range Range A Range object, representing the cell or range of cells that were edited
e.value 10 Only available if the edited range is a single cell
Form submit
(installable)
e.authMode FULL A value from the ScriptApp.AuthMode enum
e.values ['2015/05/04 15:00', 'amin@example.com', 'Bob', '27', 'Bill', '28', 'Susan', '25'] Array with values in the same order as they appear in the spreadsheet
e.range Range A Range object, representing the cell or range of cells that were edited
e.namedValues {'First Name': ['Jane'], 'Timestamp': ['6/7/2015 20:54:13'], 'Last Name': ['Doe']} An object containing the question names and values from the form submission

Google Docs events

Triggers allow Google Docs to respond when a user opens a document.

Event Type Field Example Notes
Open
(simple and installable)
e.authMode LIMITED A value from the ScriptApp.AuthMode enum
e.source Document A Document object, representing the Google Docs file to which the script is bound
e.user amin@example.com A User object, representing the owner of the document (only available in simple triggers, and only if the current user is allowed to know the owner's email address, depending on a complex set of security restrictions)

Google Forms events

The Google Forms-specific triggers let scripts respond when a user edits a form or submits a response.

Event Type Field Example Notes
Open*
(simple and installable)
e.authMode LIMITED A value from the ScriptApp.AuthMode enum
e.source Form A Form object, representing the Google Forms file to which the script is bound
e.user amin@example.com A User object, representing the owner of the form (only available in simple triggers, and only if the current user is allowed to know the owner's email address, depending on a complex set of security restrictions)
Form submit
(installable)
e.authMode FULL A value from the ScriptApp.AuthMode enum
e.response FormResponse A FormResponse object, representing the user's response to the form as a whole
e.source Form A Form object, representing the Google Forms file to which the script is bound

* This event does not occur when a user opens a form to respond, but rather when an editor opens the form to modify it.

Add-on installation events

The onInstall() trigger runs automatically when a user installs an add-on.

Event Type Field Example Notes
Install (simple) e.authMode FULL A value from the ScriptApp.AuthMode enum

Time-driven events

Time-driven triggers (also called clock triggers) let scripts execute at a particular time or on a recurring interval.

Field Example Notes
e.authMode FULL A value from the ScriptApp.AuthMode enum
e.year 2015
e.month 12 Between 1 and 12
e["day-of-month"] 31 Between 1 and 31
e["day-of-week"] 7 Between 1 (Monday) and 7 (Sunday)
e["week-of-year"] 52 Between 1 and 52
e.hour 23 Between 0 and 23
e.minute 59 Between 0 and 59
e.second 59 Between 0 and 59
e.timezone UTC