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