[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eTriggerBuilder provides a generic way to create script triggers for various Google Apps Script services like Documents, Forms, Spreadsheets, and Calendar.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods like \u003ccode\u003eforDocument()\u003c/code\u003e, \u003ccode\u003eforForm()\u003c/code\u003e, \u003ccode\u003eforSpreadsheet()\u003c/code\u003e, \u003ccode\u003eforUserCalendar()\u003c/code\u003e, and \u003ccode\u003etimeBased()\u003c/code\u003e to build triggers based on specific events or schedules.\u003c/p\u003e\n"],["\u003cp\u003eEach method returns a corresponding builder object (e.g., DocumentTriggerBuilder, FormTriggerBuilder) that allows for further customization of the trigger.\u003c/p\u003e\n"],["\u003cp\u003eTriggerBuilder methods require specific authorization scopes to access and modify the respective services.\u003c/p\u003e\n"],["\u003cp\u003eUsers can chain methods to define trigger conditions, such as \u003ccode\u003eonOpen()\u003c/code\u003e, \u003ccode\u003eonFormSubmit()\u003c/code\u003e, \u003ccode\u003eonEdit()\u003c/code\u003e, or scheduling using \u003ccode\u003etimeBased()\u003c/code\u003e.\u003c/p\u003e\n"]]],["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"],null,["TriggerBuilder\n\nA generic builder for script triggers. \n\nMethods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------|----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [forDocument(document)](#forDocument(Document)) | [DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) | Creates and returns a [DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) tied to the given document. |\n| [forDocument(key)](#forDocument(String)) | [DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) | Creates and returns a [DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) tied to the document with the given ID. |\n| [forForm(form)](#forForm(Form)) | [FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) | Creates and returns a [FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) tied to the given form. |\n| [forForm(key)](#forForm(String)) | [FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) | Creates and returns a [FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) tied to the form with the given ID. |\n| [forSpreadsheet(sheet)](#forSpreadsheet(Spreadsheet)) | [SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) | Creates and returns a [SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) tied to the given spreadsheet. |\n| [forSpreadsheet(key)](#forSpreadsheet(String)) | [SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) | Creates and returns a [SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) tied to the spreadsheet with the given ID. |\n| [forUserCalendar(emailId)](#forUserCalendar(String)) | [CalendarTriggerBuilder](/apps-script/reference/script/calendar-trigger-builder) | Returns a builder for building calendar triggers. |\n| [timeBased()](#timeBased()) | [ClockTriggerBuilder](/apps-script/reference/script/clock-trigger-builder) | Creates and returns a [ClockTriggerBuilder](/apps-script/reference/script/clock-trigger-builder) for building time-based triggers. |\n\nDetailed documentation \n\n`for``Document(document)` \nCreates and returns a [DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) tied to the given document.\n\n```javascript\nScriptApp.newTrigger('myFunction')\n .forDocument(DocumentApp.getActiveDocument())\n .onOpen()\n .create();\n```\n\nParameters\n\n| Name | Type | Description |\n|------------|---------------------------------------|--------------|\n| `document` | [Document](../document/document.html) | the document |\n\nReturn\n\n\n[DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) --- the new DocumentTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`for``Document(key)` \nCreates and returns a [DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) tied to the document with the given ID.\n\n```javascript\nScriptApp.newTrigger('myFunction')\n .forDocument('1234567890abcdefghijklmnopqrstuvwxyz')\n .onOpen()\n .create();\n```\n\nParameters\n\n| Name | Type | Description |\n|-------|----------|-------------------------|\n| `key` | `String` | the ID for the document |\n\nReturn\n\n\n[DocumentTriggerBuilder](/apps-script/reference/script/document-trigger-builder) --- the new DocumentTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`for``Form(form)` \nCreates and returns a [FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) tied to the given form.\n\n```javascript\nScriptApp.newTrigger('myFunction')\n .forForm(FormApp.getActiveForm())\n .onFormSubmit()\n .create();\n```\n\nParameters\n\n| Name | Type | Description |\n|--------|----------------------------|-------------|\n| `form` | [Form](../forms/form.html) | the form |\n\nReturn\n\n\n[FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) --- the new FormTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`for``Form(key)` \nCreates and returns a [FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) tied to the form with the given ID.\n\n```javascript\nScriptApp.newTrigger('myFunction')\n .forForm('1234567890abcdefghijklmnopqrstuvwxyz')\n .onFormSubmit()\n .create();\n```\n\nParameters\n\n| Name | Type | Description |\n|-------|----------|---------------------|\n| `key` | `String` | the ID for the form |\n\nReturn\n\n\n[FormTriggerBuilder](/apps-script/reference/script/form-trigger-builder) --- the new FormTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`for``Spreadsheet(sheet)` \nCreates and returns a [SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) tied to the given spreadsheet.\n\n```javascript\nScriptApp.newTrigger('myFunction')\n .forSpreadsheet(SpreadsheetApp.getActive())\n .onEdit()\n .create();\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|------------------------------------------------|-----------------|\n| `sheet` | [Spreadsheet](../spreadsheet/spreadsheet.html) | the spreadsheet |\n\nReturn\n\n\n[SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) --- the new SpreadsheetTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`for``Spreadsheet(key)` \nCreates and returns a [SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) tied to the spreadsheet with the given\nID.\n\n```javascript\nScriptApp.newTrigger('myFunction')\n .forSpreadsheet('1234567890abcdefghijklmnopqrstuvwxyz')\n .onEdit()\n .create();\n```\n\nParameters\n\n| Name | Type | Description |\n|-------|----------|----------------------------|\n| `key` | `String` | the ID for the spreadsheet |\n\nReturn\n\n\n[SpreadsheetTriggerBuilder](/apps-script/reference/script/spreadsheet-trigger-builder) --- the new SpreadsheetTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`for``User``Calendar(emailId)` \nReturns a builder for building calendar triggers.\n\nParameters\n\n| Name | Type | Description |\n|-------------|----------|-----------------------------------------------------|\n| `email``Id` | `String` | email ID of the user calendar the trigger monitors. |\n\nReturn\n\n\n[CalendarTriggerBuilder](/apps-script/reference/script/calendar-trigger-builder) --- The new CalendarTriggerBuilder.\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/calendar`\n- `https://www.googleapis.com/auth/calendar.readonly`\n- `https://www.googleapis.com/auth/calendar.events`\n- `https://www.googleapis.com/auth/calendar.events.readonly`\n- `https://www.google.com/calendar/feeds`\n\n*** ** * ** ***\n\n`time``Based()` \nCreates and returns a [ClockTriggerBuilder](/apps-script/reference/script/clock-trigger-builder) for building time-based triggers.\n\n```javascript\nScriptApp.newTrigger('myFunction').timeBased().atDate(2013, 10, 31).create();\n```\n\nReturn\n\n\n[ClockTriggerBuilder](/apps-script/reference/script/clock-trigger-builder) --- the new ClockTriggerBuilder\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/script.scriptapp`"]]