程式設計層級:入門
時間長度:15 分鐘
專案類型:透過事件導向觸發條件執行自動化動作
目標
- 瞭解解決方案的功能。
- 瞭解 Apps Script 服務在 解決方案
- 設定指令碼。
- 執行指令碼。
認識這項解決方案
自動在 Google 文件中建立議程文件,然後附加到 Google 日曆會議。
運作方式
指令碼會為議程建立文件範本,當您更新 日曆,指令碼會檢查您是否有活動包含「#agenda」英吋 例如說明如果有這個標記,指令碼就會複製範本 將日曆新增至日曆活動,然後與活動參與者分享。
Apps Script 服務
這項解決方案使用下列服務:
- 雲端硬碟服務:檢查範本是否違規 文件,如果沒有,請為範本建立新資料夾 文件。 為每項新議程建立範本文件副本。
- 文件服務:建立議程 範本。
- 日曆服務:檢查含有以下內容的活動: 「#agenda」標記並更新活動說明,同時附上議程連結 文件。
- 基礎服務:使用
Session
類別取得 使用者的電子郵件。這有助於為目前的使用者建立觸發條件。 - 指令碼服務:建立會啟動的觸發條件 這類事件。
必要條件
如要使用這個範例,您必須具備下列先決條件:
- Google 帳戶 (Google Workspace 帳戶可能會 需要管理員核准)。
- 可存取網際網路的網路瀏覽器。
設定指令碼
- 點選下方按鈕即可開啟「製作會議議程」範例
Apps Script 專案。
開啟專案 - 按一下「總覽」圖示 。
- 在總覽頁面中,按一下「建立副本」圖示 。
- 在複製的專案中,選取函式下拉式選單中的「setUp」setUp。
- 按一下「執行」。
- 出現提示時,請授權指令碼。 如果 OAuth 同意畫面顯示「這個應用程式未經驗證」警告, 如要繼續,請選取「進階」圖示 > 前往 {Project Name} (不安全)。
執行指令碼
- 開啟 Google 日曆。
- 建立新事件或編輯現有事件。
- 在說明中加入
#agenda
並儲存事件。 - 請查看電子郵件,確認文件是否已設為共用的電子郵件通知 或者重新整理「日曆」並按一下 活動,即可查看議程文件連結。
所有參與者都會收到查看議程的電子郵件通知。 指令碼會授權參與者進行編輯,但你可以編輯腳本來更新 授予與會者的議程文件權限。
查看程式碼
如要查看這個解決方案的 Apps Script 程式碼,請按一下 查看原始碼如下:
查看原始碼
Code.gs
修正規則
您可以視需求編輯樣本,數量不限。以下是 並視需要調整
更新參與者的議程文件權限
指令碼會授予參與者編輯權限。如果您想
將權限限制為僅供檢視,請替換 addEditor
方法
在程式碼的以下部分使用 addViewer
方法:
for (let i in event.getGuestList()) { let guest = event.getGuestList()[i]; newDoc.addEditor(guest.getEmail());
編輯議程文件範本
如要更新議程文件範本,請按照下列步驟操作:
- 在日曆活動中建立第一項待辦事項後,開啟 Google 雲端硬碟。
- 開啟「待辦事項製作工具 - 應用程式」資料夾。
- 開啟「待辦事項 TEMPLATE##」文件並進行編輯。
貢獻者
這個範例是由產品管理與平台的 Jeremy Glassenberg 所製作 策略顧問。在 Twitter 尋找 Jeremy:@jglassenberg。
這個範例是由 Google 在 Google Developers 專家的協助下維護。