A generic builder for script triggers.
Methods
Method | Return type | Brief description |
---|---|---|
forDocument(document) | DocumentTriggerBuilder | Creates and returns a DocumentTriggerBuilder tied to the given document. |
forDocument(key) | DocumentTriggerBuilder | Creates and returns a DocumentTriggerBuilder tied to the document with the given ID. |
forForm(form) | FormTriggerBuilder | Creates and returns a FormTriggerBuilder tied to the given form. |
forForm(key) | FormTriggerBuilder | Creates and returns a FormTriggerBuilder tied to the form with the given ID. |
forSpreadsheet(sheet) | SpreadsheetTriggerBuilder | Creates and returns a SpreadsheetTriggerBuilder tied to the given spreadsheet. |
forSpreadsheet(key) | SpreadsheetTriggerBuilder | Creates and returns a SpreadsheetTriggerBuilder tied to the spreadsheet with the given
ID. |
forUserCalendar(emailId) | CalendarTriggerBuilder | Returns a builder for building calendar triggers. |
timeBased() | ClockTriggerBuilder | Creates and returns a ClockTriggerBuilder for building time-based triggers. |
Detailed documentation
forDocument(document)
Creates and returns a DocumentTriggerBuilder
tied to the given document.
ScriptApp.newTrigger('myFunction')
.forDocument(DocumentApp.getActiveDocument())
.onOpen()
.create();
Parameters
Name | Type | Description |
---|---|---|
document | Document | the document |
Return
DocumentTriggerBuilder
— the new DocumentTriggerBuilder
forDocument(key)
Creates and returns a DocumentTriggerBuilder
tied to the document with the given ID.
ScriptApp.newTrigger('myFunction')
.forDocument('1234567890abcdefghijklmnopqrstuvwxyz')
.onOpen()
.create();
Parameters
Name | Type | Description |
---|---|---|
key | String | the ID for the document |
Return
DocumentTriggerBuilder
— the new DocumentTriggerBuilder
forForm(form)
Creates and returns a FormTriggerBuilder
tied to the given form.
ScriptApp.newTrigger('myFunction')
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
Parameters
Name | Type | Description |
---|---|---|
form | Form | the 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
Name | Type | Description |
---|---|---|
key | String | the 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
Name | Type | Description |
---|---|---|
sheet | Spreadsheet | the 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
Name | Type | Description |
---|---|---|
key | String | the ID for the spreadsheet |
Return
SpreadsheetTriggerBuilder
— the new SpreadsheetTriggerBuilder
forUserCalendar(emailId)
Returns a builder for building calendar triggers.
Parameters
Name | Type | Description |
---|---|---|
emailId | String | email ID of the user calendar the trigger monitors. |
Return
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