Class SpreadsheetTriggerBuilder

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.

var sheet = 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.

var sheet = 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.

var sheet = 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.

var sheet = SpreadsheetApp.getActive();
ScriptApp.newTrigger("myFunction")
  .forSpreadsheet(sheet)
  .onOpen()
  .create();

Return

SpreadsheetTriggerBuilder — a builder for chaining