指令碼觸發條件的通用建構工具。
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
for | Document | 建立並傳回與指定文件相關聯的 Document。 |
for | Document | 建立並傳回與指定 ID 文件相關聯的 Document。 |
for | Form | 建立並傳回與指定表單相關聯的 Form。 |
for | Form | 建立並傳回與指定 ID 表單相關聯的 Form。 |
for | Spreadsheet | 建立並傳回與指定試算表相關聯的 Spreadsheet。 |
for | Spreadsheet | 建立並傳回與指定 ID 的試算表相關聯的 Spreadsheet。 |
for | Calendar | 傳回用於建構日曆觸發條件的建構工具。 |
time | Clock | 建立並傳回 Clock,用於建構時間觸發條件。 |
內容詳盡的說明文件
forDocument(document)
建立並傳回與指定文件相關聯的 DocumentTriggerBuilder。
ScriptApp.newTrigger('myFunction') .forDocument(DocumentApp.getActiveDocument()) .onOpen() .create();
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
document | Document | 文件。 |
回攻員
DocumentTriggerBuilder - 新的 DocumentTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
forDocument(key)
建立並傳回與指定 ID 文件相關聯的 DocumentTriggerBuilder。
ScriptApp.newTrigger('myFunction') .forDocument('1234567890abcdefghijklmnopqrstuvwxyz') .onOpen() .create();
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
key | String | 文件的 ID。 |
回攻員
DocumentTriggerBuilder - 新的 DocumentTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
forForm(form)
建立並傳回與指定表單相關聯的 FormTriggerBuilder。
ScriptApp.newTrigger('myFunction') .forForm(FormApp.getActiveForm()) .onFormSubmit() .create();
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
form | Form | 表單。 |
回攻員
FormTriggerBuilder - 新的 FormTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
forForm(key)
建立並傳回與指定 ID 表單相關聯的 FormTriggerBuilder。
ScriptApp.newTrigger('myFunction') .forForm('1234567890abcdefghijklmnopqrstuvwxyz') .onFormSubmit() .create();
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
key | String | 表單的 ID。 |
回攻員
FormTriggerBuilder - 新的 FormTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
forSpreadsheet(sheet)
建立並傳回與指定試算表相關聯的 SpreadsheetTriggerBuilder。
ScriptApp.newTrigger('myFunction') .forSpreadsheet(SpreadsheetApp.getActive()) .onEdit() .create();
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
sheet | Spreadsheet | 試算表。 |
回攻員
SpreadsheetTriggerBuilder - 新的 SpreadsheetTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
forSpreadsheet(key)
建立並傳回與指定 ID 的試算表相關聯的 SpreadsheetTriggerBuilder。
ScriptApp.newTrigger('myFunction') .forSpreadsheet('1234567890abcdefghijklmnopqrstuvwxyz') .onEdit() .create();
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
key | String | 試算表的 ID。 |
回攻員
SpreadsheetTriggerBuilder - 新的 SpreadsheetTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
forUserCalendar(emailId)
傳回用於建構日曆觸發條件的建構工具。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
email | String | 觸發條件監控的使用者日曆電子郵件 ID。 |
回攻員
CalendarTriggerBuilder:新的 CalendarTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
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()
建立並傳回 ClockTriggerBuilder,用於建構時間觸發條件。
ScriptApp.newTrigger('myFunction').timeBased().atDate(2013, 10, 31).create();
回攻員
ClockTriggerBuilder - 新的 ClockTriggerBuilder。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/script.scriptapp