Class TriggerBuilder

TriggerBuilder

スクリプト トリガーの汎用ビルダー。

Methods

メソッド戻り値の型概要
forDocument(document)DocumentTriggerBuilder指定されたドキュメントに関連付けられている DocumentTriggerBuilder を作成して返します。
forDocument(key)DocumentTriggerBuilder指定された ID を持つドキュメントに関連付けられている DocumentTriggerBuilder を作成して返します。
forForm(form)FormTriggerBuilder指定されたフォームに関連付けられた FormTriggerBuilder を作成して返します。
forForm(key)FormTriggerBuilder指定された ID のフォームに関連付けられた FormTriggerBuilder を作成して返します。
forSpreadsheet(sheet)SpreadsheetTriggerBuilder指定されたスプレッドシートに関連付けられている SpreadsheetTriggerBuilder を作成して返します。
forSpreadsheet(key)SpreadsheetTriggerBuilder指定された ID のスプレッドシートに関連付けられている SpreadsheetTriggerBuilder を作成して返します。
forUserCalendar(emailId)CalendarTriggerBuilderカレンダー トリガーを作成するためのビルダーを返します。
timeBased()ClockTriggerBuilder時間ベースのトリガーを作成するための ClockTriggerBuilder を作成して返します。

詳細なドキュメント

forDocument(document)

指定されたドキュメントに関連付けられている DocumentTriggerBuilder を作成して返します。

ScriptApp.newTrigger('myFunction')
  .forDocument(DocumentApp.getActiveDocument())
  .onOpen()
  .create();

パラメータ

名前説明
documentDocumentドキュメント

リターン

DocumentTriggerBuilder - 新しい DocumentTriggerBuilder

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

forDocument(key)

指定された ID を持つドキュメントに関連付けられている DocumentTriggerBuilder を作成して返します。

ScriptApp.newTrigger('myFunction')
  .forDocument('1234567890abcdefghijklmnopqrstuvwxyz')
  .onOpen()
  .create();

パラメータ

名前説明
keyStringドキュメントの ID

リターン

DocumentTriggerBuilder - 新しい DocumentTriggerBuilder

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

forForm(form)

指定されたフォームに関連付けられた FormTriggerBuilder を作成して返します。

ScriptApp.newTrigger('myFunction')
  .forForm(FormApp.getActiveForm())
  .onFormSubmit()
  .create();

パラメータ

名前説明
formFormフォーム

リターン

FormTriggerBuilder - 新しい FormTriggerBuilder

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

forForm(key)

指定された ID のフォームに関連付けられた FormTriggerBuilder を作成して返します。

ScriptApp.newTrigger('myFunction')
  .forForm('1234567890abcdefghijklmnopqrstuvwxyz')
  .onFormSubmit()
  .create();

パラメータ

名前説明
keyStringフォームの ID

リターン

FormTriggerBuilder - 新しい FormTriggerBuilder

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

forSpreadsheet(sheet)

指定されたスプレッドシートに関連付けられている SpreadsheetTriggerBuilder を作成して返します。

ScriptApp.newTrigger('myFunction')
  .forSpreadsheet(SpreadsheetApp.getActive())
  .onEdit()
  .create();

パラメータ

名前説明
sheetSpreadsheetスプレッドシート

リターン

SpreadsheetTriggerBuilder - 新しい spreadsheetsTriggerBuilder

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

forSpreadsheet(key)

指定された ID のスプレッドシートに関連付けられている SpreadsheetTriggerBuilder を作成して返します。

ScriptApp.newTrigger('myFunction')
  .forSpreadsheet('1234567890abcdefghijklmnopqrstuvwxyz')
  .onEdit()
  .create();

パラメータ

名前説明
keyStringスプレッドシートの ID

リターン

SpreadsheetTriggerBuilder - 新しい spreadsheetsTriggerBuilder

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

forUserCalendar(emailId)

カレンダー トリガーを作成するためのビルダーを返します。

パラメータ

名前説明
emailIdStringトリガーがモニタリングするユーザー カレンダーのメール ID。

リターン

CalendarTriggerBuilder - 新しい CalendarTriggerBuilder。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • 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

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

  • https://www.googleapis.com/auth/script.scriptapp