Stay organized with collections Save and categorize content based on your preferences.
TriggerBuilderA generic builder for script triggers.
Detailed documentationforDocument(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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
forUserCalendar(emailId)
Returns a builder for building calendar triggers.
Parameters Name Type DescriptionemailId
String
email ID of the user calendar the trigger monitors. Return
CalendarTriggerBuilder
— The new CalendarTriggerBuilder.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/auth/calendar.events
https://www.googleapis.com/auth/calendar.events.readonly
https://www.google.com/calendar/feeds
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
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/script.scriptapp
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["TriggerBuilder provides a generic way to create script triggers for various Google Apps Script services like Documents, Forms, Spreadsheets, and Calendar."],["It offers methods like `forDocument()`, `forForm()`, `forSpreadsheet()`, `forUserCalendar()`, and `timeBased()` to build triggers based on specific events or schedules."],["Each method returns a corresponding builder object (e.g., DocumentTriggerBuilder, FormTriggerBuilder) that allows for further customization of the trigger."],["TriggerBuilder methods require specific authorization scopes to access and modify the respective services."],["Users can chain methods to define trigger conditions, such as `onOpen()`, `onFormSubmit()`, `onEdit()`, or scheduling using `timeBased()`."]]],["The `TriggerBuilder` allows creation of script triggers for various applications. It supports building triggers for documents, forms, and spreadsheets, either by providing the object or its ID. It returns `DocumentTriggerBuilder`, `FormTriggerBuilder`, or `SpreadsheetTriggerBuilder` respectively. It can also build calendar triggers with `CalendarTriggerBuilder` for user-specified calendars and time-based triggers via `ClockTriggerBuilder`. Each trigger type is built using specific methods like `forDocument`, `forForm`, `forSpreadsheet`, `forUserCalendar`, or `timeBased`.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4