Class SpreadsheetTriggerBuilder
Stay organized with collections
Save and categorize content based on your preferences.
SpreadsheetTriggerBuilder
Builder for spreadsheet triggers.
Detailed documentation
create()
Creates the trigger and returns it.
Return
Trigger
— The created trigger.
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
SpreadsheetTriggerBuilder
— 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
SpreadsheetTriggerBuilder
— 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
SpreadsheetTriggerBuilder
— a builder for chaining
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.
[null,null,["Last updated 2024-12-02 UTC."],[[["\u003cp\u003eSpreadsheetTriggerBuilder facilitates the creation and customization of triggers specific to Google Spreadsheets.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to set triggers for various events, such as changes in content or structure (\u003ccode\u003eonChange()\u003c/code\u003e), edits (\u003ccode\u003eonEdit()\u003c/code\u003e), form submissions (\u003ccode\u003eonFormSubmit()\u003c/code\u003e), and spreadsheet opening (\u003ccode\u003eonOpen()\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eEach trigger specification method returns a builder object, enabling chained configurations for flexibility and conciseness in trigger setup.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecreate()\u003c/code\u003e method finalizes the trigger definition and returns a Trigger object, instantiating the trigger for execution based on the specified event.\u003c/p\u003e\n"]]],[],null,["# Class SpreadsheetTriggerBuilder\n\nSpreadsheetTriggerBuilder\n\nBuilder for spreadsheet triggers. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------|--------------------------------------------------|--------------------------------------------------------------------------------------------|\n| [create()](#create()) | [Trigger](/apps-script/reference/script/trigger) | Creates the trigger and returns it. |\n| [onChange()](#onChange()) | [SpreadsheetTriggerBuilder](#) | Specifies a trigger that will fire when the spreadsheet's content or structure is changed. |\n| [onEdit()](#onEdit()) | [SpreadsheetTriggerBuilder](#) | Specifies a trigger that will fire when the spreadsheet is edited. |\n| [onFormSubmit()](#onFormSubmit()) | [SpreadsheetTriggerBuilder](#) | Specifies a trigger that will fire when the spreadsheet has a form submitted to it. |\n| [onOpen()](#onOpen()) | [SpreadsheetTriggerBuilder](#) | Specifies a trigger that will fire when the spreadsheet is opened. |\n\nDetailed documentation\n----------------------\n\n### `create()`\n\nCreates the trigger and returns it.\n\n#### Return\n\n\n[Trigger](/apps-script/reference/script/trigger) --- The created trigger.\n\n*** ** * ** ***\n\n### `on``Change()`\n\nSpecifies a trigger that will fire when the spreadsheet's content or structure is changed.\n\n```javascript\nconst sheet = SpreadsheetApp.getActive();\nScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onChange().create();\n```\n\n#### Return\n\n\n[SpreadsheetTriggerBuilder](#) --- a builder for chaining\n\n*** ** * ** ***\n\n### `on``Edit()`\n\nSpecifies a trigger that will fire when the spreadsheet is edited.\n\n```javascript\nconst sheet = SpreadsheetApp.getActive();\nScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onEdit().create();\n```\n\n#### Return\n\n\n[SpreadsheetTriggerBuilder](#) --- a builder for chaining\n\n*** ** * ** ***\n\n### `on``Form``Submit()`\n\nSpecifies a trigger that will fire when the spreadsheet has a form submitted to it.\n\n```javascript\nconst sheet = SpreadsheetApp.getActive();\nScriptApp.newTrigger('myFunction')\n .forSpreadsheet(sheet)\n .onFormSubmit()\n .create();\n```\n\n#### Return\n\n\n[SpreadsheetTriggerBuilder](#) --- A builder for chaining.\n\n*** ** * ** ***\n\n### `on``Open()`\n\nSpecifies a trigger that will fire when the spreadsheet is opened.\n\n```javascript\nconst sheet = SpreadsheetApp.getActive();\nScriptApp.newTrigger('myFunction').forSpreadsheet(sheet).onOpen().create();\n```\n\n#### Return\n\n\n[SpreadsheetTriggerBuilder](#) --- a builder for chaining"]]