Google Apps Script

Class TriggerBuilder

A generic builder for script triggers.

Methods

MethodReturn typeBrief description
forForm(form)FormTriggerBuilderCreates and returns a FormTriggerBuilder tied to the given form.
forForm(key)FormTriggerBuilderCreates and returns a FormTriggerBuilder tied to the form with the given ID.
forSpreadsheet(sheet)SpreadsheetTriggerBuilderCreates and returns a SpreadsheetTriggerBuilder tied to the given spreadsheet.
forSpreadsheet(key)SpreadsheetTriggerBuilderCreates and returns a SpreadsheetTriggerBuilder tied to the spreadsheet with the given ID.
timeBased()ClockTriggerBuilderCreates and returns a ClockTriggerBuilder for building time-based triggers.

Detailed documentation

forForm(form)

Creates and returns a FormTriggerBuilder tied to the given form.

 
ScriptApp.newTrigger('myFunction')
   .forForm(FormApp.getActiveForm())
   .onFormSubmit()
   .create();
 

Parameters

NameTypeDescription
formFormthe form

Return

FormTriggerBuilder — the new FormTriggerBuilder


forForm(key)

Creates and returns a FormTriggerBuilder tied to the form with the given ID.

 
ScriptApp.newTrigger('myFunction')
   .forForm('1234567890abcdefghijklmnopqrstuvwxyz')
   .onFormSubmit()
   .create();
 

Parameters

NameTypeDescription
keyStringthe ID for the form

Return

FormTriggerBuilder — the new FormTriggerBuilder


forSpreadsheet(sheet)

Creates and returns a SpreadsheetTriggerBuilder tied to the given spreadsheet.

 
ScriptApp.newTrigger('myFunction')
   .forSpreadsheet(SpreadsheetApp.getActive())
   .onEdit()
   .create();
 

Parameters

NameTypeDescription
sheetSpreadsheetthe spreadsheet

Return

SpreadsheetTriggerBuilder — the new SpreadsheetTriggerBuilder


forSpreadsheet(key)

Creates and returns a SpreadsheetTriggerBuilder tied to the spreadsheet with the given ID.

 
ScriptApp.newTrigger('myFunction')
   .forSpreadsheet('1234567890abcdefghijklmnopqrstuvwxyz')
   .onEdit()
   .create();
 

Parameters

NameTypeDescription
keyStringthe ID for the spreadsheet

Return

SpreadsheetTriggerBuilder — the new SpreadsheetTriggerBuilder


timeBased()

Creates and returns a ClockTriggerBuilder for building time-based triggers.

 
ScriptApp.newTrigger('myFunction')
   .timeBased()
   .atDate(2013, 10, 31)
   .create();
 

Return

ClockTriggerBuilder — the new ClockTriggerBuilder

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.