AI-generated Key Takeaways
-
SpreadsheetTriggerBuilder facilitates the creation and customization of triggers specific to Google Spreadsheets.
-
It offers methods to set triggers for various events, such as changes in content or structure (
onChange()
), edits (onEdit()
), form submissions (onFormSubmit()
), and spreadsheet opening (onOpen()
). -
Each trigger specification method returns a builder object, enabling chained configurations for flexibility and conciseness in trigger setup.
-
The
create()
method finalizes the trigger definition and returns a Trigger object, instantiating the trigger for execution based on the specified event.
Builder for spreadsheet triggers.
Methods
Method | Return type | Brief description |
---|---|---|
create() | Trigger | Creates the trigger and returns it. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet's content or structure is changed. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet is edited. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet has a form submitted to it. |
on | Spreadsheet | Specifies a trigger that will fire when the spreadsheet is opened. |
Detailed documentation
create()
onChange()
Specifies a trigger that will fire when the spreadsheet's content or structure is changed.
const sheet = SpreadsheetApp.getActive(); ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onChange().create();
Return
Spreadsheet
— a builder for chaining
onEdit()
Specifies a trigger that will fire when the spreadsheet is edited.
const sheet = SpreadsheetApp.getActive(); ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onEdit().create();
Return
Spreadsheet
— a builder for chaining
onFormSubmit()
Specifies a trigger that will fire when the spreadsheet has a form submitted to it.
const sheet = SpreadsheetApp.getActive(); ScriptApp.newTrigger('myFunction') .forSpreadsheet(sheet) .onFormSubmit() .create();
Return
Spreadsheet
— A builder for chaining.
onOpen()
Specifies a trigger that will fire when the spreadsheet is opened.
const sheet = SpreadsheetApp.getActive(); ScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onOpen().create();
Return
Spreadsheet
— a builder for chaining