Class SpreadsheetTriggerBuilder Stay organized with collections Save and categorize content based on your preferences.
Page Summary
SpreadsheetTriggerBuilder is a builder used to create triggers for spreadsheets.
You can create triggers that fire on changes, edits, form submissions, or when the spreadsheet is opened.
The
create()method finalizes and returns the trigger.Methods like
onChange(),onEdit(),onFormSubmit(), andonOpen()return the builder for method chaining.
Builder for spreadsheet triggers.
Methods
| Method | Return type | Brief description |
|---|---|---|
create() | Trigger | Creates the trigger and returns it. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet's content or structure is changed. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet is edited. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet has a form submitted to it. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet is opened. |
Detailed documentation
create()
onChange()
Specifies a trigger that will fire when the spreadsheet's content or structure is changed.
constsheet=SpreadsheetApp.getActive();ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onChange().create();
Return
Spreadsheet — a builder for chaining
onEdit()
Specifies a trigger that will fire when the spreadsheet is edited.
constsheet=SpreadsheetApp.getActive();ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onEdit().create();
Return
Spreadsheet — a builder for chaining
onFormSubmit()
Specifies a trigger that will fire when the spreadsheet has a form submitted to it.
constsheet=SpreadsheetApp.getActive();ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onFormSubmit().create();
Return
Spreadsheet — A builder for chaining.
onOpen()
Specifies a trigger that will fire when the spreadsheet is opened.
constsheet=SpreadsheetApp.getActive();ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onOpen().create();
Return
Spreadsheet — a builder for chaining
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.