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.

  • The create() method finalizes and returns the trigger.

  • Methods like onChange(), onEdit(), onFormSubmit(), and onOpen() return the builder for method chaining.

SpreadsheetTriggerBuilder

Builder for spreadsheet triggers.

Methods

MethodReturn typeBrief description
create() Trigger Creates the trigger and returns it.
onChange() SpreadsheetTriggerBuilder Specifies a trigger that will fire when the spreadsheet's content or structure is changed.
onEdit() SpreadsheetTriggerBuilder Specifies a trigger that will fire when the spreadsheet is edited.
onFormSubmit() SpreadsheetTriggerBuilder Specifies a trigger that will fire when the spreadsheet has a form submitted to it.
onOpen() SpreadsheetTriggerBuilder Specifies 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 the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年12月02日 UTC.