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

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/script.scriptapp

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

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/script.scriptapp

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

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/script.scriptapp

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

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/script.scriptapp

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

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.googleapis.com/auth/script.scriptapp

Send feedback about...

Apps Script
Apps Script
Need help? Visit our support page.