已淘汰。這個類別已淘汰,不應用於新指令碼。
這個類別已淘汰,請改用 Decorated。
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
add | Widget | 新增可在小工具上執行的事件動作。 |
set | | 設定授權動作,在點選物件時開啟授權流程的網址。 |
set | | 設定動作,在點選物件時撰寫電子郵件草稿。 |
set | Widget | 設定指派的專屬 ID,用於識別要變動的小工具。 |
set | | 設定在點選物件時執行的動作。 |
set | | 設定動作,在點選物件時於分頁中開啟網址。 |
set | | 設定點選物件時要開啟的網址。 |
set | Widget | 設定小工具的顯示設定。 |
內容詳盡的說明文件
add Event Action(eventAction)
set Authorization Action(action)
設定授權動作,在點選物件時開啟授權流程的網址。系統隨即會在新視窗中開啟網址。使用者完成授權流程並返回應用程式後,外掛程式會重新載入。
UI 物件只能設定 set、set、set、set 或 set 的其中一個。
// ... const action = CardService.newAuthorizationAction().setAuthorizationUrl('url'); CardService.newTextButton().setText('Authorize').setAuthorizationAction(action);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
action | Authorization | 這個物件會指定點選這個元素時要採取的授權動作。 |
回攻員
- 這個物件,用於鏈結。Key
set Compose Action(action, composedEmailType)
設定動作,在點選物件時撰寫電子郵件草稿。UI 物件只能設定 set、set、set、set 或 set 的其中一個。
Action 參數必須指定回呼函式,該函式會傳回使用 Compose 設定的 Compose 物件。
// ... const action = CardService.newAction().setFunctionName('composeEmailCallback'); CardService.newTextButton() .setText('Compose Email') .setComposeAction(action, CardService.ComposedEmailType.REPLY_AS_DRAFT); // ... function composeEmailCallback(e) { const thread = GmailApp.getThreadById(e.threadId); const draft = thread.createDraftReply('This is a reply'); return CardService.newComposeActionResponseBuilder() .setGmailDraft(draft) .build(); }
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
action | Action | 這個物件會指定點選這個元素時要採取的撰寫動作。 |
composed | Composed | 列舉值,用於指定撰寫的草稿是獨立草稿還是回覆草稿。 |
回攻員
- 這個物件,用於鏈結。Key
set Id(id)
設定指派的專屬 ID,用於識別要變動的小工具。外掛程式僅支援小工具突變。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
id | String | 小工具的 ID,最多 64 個字元,格式為 `[a-zA-Z0-9-]+`。 |
回攻員
Widget - 這個物件,用於鏈結。
set On Click Action(action)
設定在點選物件時執行的動作。UI 物件只能設定 set、set、set、set 或 set 的其中一個。
Action 參數必須指定會傳回 Action 物件的回呼函式。
// ... const action = CardService.newAction().setFunctionName('notificationCallback'); CardService.newTextButton() .setText('Create notification') .setOnClickAction(action); // ... function notificationCallback() { return CardService.newActionResponseBuilder() .setNotification( CardService.newNotification().setText('Some info to display to user'), ) .build(); }
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
action | Action | 點選這個元素時要採取的動作。 |
回攻員
- 這個物件,用於鏈結。Key
set On Click Open Link Action(action)
設定動作,在點選物件時於分頁中開啟網址。如果需要建構網址,或除了建立 Open 物件外,還需要採取其他動作,請使用這個函式。UI 物件只能設定 set、set、set、set 或 set 其中一個。
Action 參數必須指定回呼函式,該函式會傳回使用 Action 設定的 Action 物件。
// ... const action = CardService.newAction().setFunctionName('openLinkCallback'); CardService.newTextButton() .setText('Open Link') .setOnClickOpenLinkAction(action); // ... function openLinkCallback() { return CardService.newActionResponseBuilder() .setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com')) .build(); }
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
action | Action | 這個物件會指定點選這個元素時要採取的開啟連結動作。 |
回攻員
- 這個物件,用於鏈結。Key
set Open Link(openLink)
設定在點選物件時開啟的網址。如果網址已知且只需要開啟,請使用這項函式。UI 物件只能設定 set、set、set、set 或 set 其中一個。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
open | Open | 說明要開啟網址的 Open 物件。 |
回攻員
- 這個物件,用於鏈結。Key