前提
言語:GAS
PC:Mac Book
実現したいこと
GoogleSpreadSheetを編集(onEditを利用、もしくはトリガーで)
↓
Slackに変更前と変更後の値を通知したい
発生している問題・エラーメッセージ
Exception: UrlFetchApp.fetch を呼び出す権限がありません。必要な権限: https://www.googleapis.com/auth/script.external_request
該当のソースコード
appscript.json
1{ 2 "timeZone": "Asia/Tokyo", 3 "dependencies": {}, 4 "oauthScopes": [ 5 "https://www.googleapis.com/auth/script.external_request", 6 "https://www.googleapis.com/auth/spreadsheets.currentonly", 7 "https://www.googleapis.com/auth/spreadsheets" 8 ], 9 "exceptionLogging": "STACKDRIVER", 10 "runtimeVersion": "V8" 11}
code.gs
1function onEdit(e) { 2~~~~~ 3省略 4~~~~~ 5let slackText = 6 "更新前のデータ :" + e.Value + "\n" + 7 "更新後のデータ :" + e.OldValue + "\n" 8; 9 10sendSlack(skackText); 11~~~~~ 12省略 13~~~~~ 14 15~~~~ 16function sendSlack(slackText){ 17 let webHookUrl = "URL"; 18 19 let jsonData = 20 { 21 "channel": "チャンネル", 22 "text": slackText, 23 "username": "テスト", 24 }; 25 26 let payload = JSON.stringify(jsonData); 27 28 let options = 29 { 30 "method": "post", 31 "contentType": "application/json", 32 "payload": payload, 33 }; 34 35 UrlFetchApp.fetch(webHookUrl, options); 36} 37
試したこと
- onEditだとUrlFetchApp.fetchだとエラーが発生する模様?
- トリガー設定すると、変更前後のデータが引用できない(日付データを引用しているが1970/01/01となる)
補足情報(FW/ツールのバージョンなど)
トリガーで変更前後の値を取得したいが方法が見当たらないため困っております。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/12/14 02:59
2022/12/14 06:59
2022/12/14 07:03
2022/12/14 07:06