Class SpreadsheetTriggerBuilder

  • 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.

  • Thecreate() method finalizes and returns the trigger.

  • Methods likeonChange(),onEdit(),onFormSubmit(), andonOpen() return the builder for method chaining.

SpreadsheetTriggerBuilder

Builder for spreadsheet triggers.

Methods

MethodReturn typeBrief description
create()TriggerCreates the trigger and returns it.
onChange()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet's content or structure is changed.
onEdit()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet is edited.
onFormSubmit()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet has a form submitted to it.
onOpen()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet is opened.

Detailed documentation

create()

Creates the trigger and returns it.

Return

Trigger — The created trigger.


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

SpreadsheetTriggerBuilder — 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

SpreadsheetTriggerBuilder — 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

SpreadsheetTriggerBuilder — 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

SpreadsheetTriggerBuilder — 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.