スプレッドシートで特定の行列の値が特定の変更をされたらSlackに通知する
5251 ワード
以下の sendNotification
をトリガーで「変更時」に発火するように設定
function sendNotification() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
const sheet = ss.getSheetByName("シート1")
const cell = ss.getActiveCell().getA1Notation()
const changedCellRow = sheet.getActiveCell().getRowIndex()
const value = sheet.getRange(cell).getValue()
const message = createMessage(changedCellRow)
if(value === "特定の変更") {
notificationToSlack(message)
}
}
function createMessage(changedCellRow) {
return "ステータスが変更されました"
}
function notificationToSlack(message) {
const postUrl = "https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXX"
const userName = 'マイメロ'
const room = "#random"
const jsonData =
{
"username" : userName,
"text": message,
"channel": room,
}
const payload = JSON.stringify(jsonData)
const options =
{
"method" : "post",
"contentType" : "application/json",
"payload" : payload
}
UrlFetchApp.fetch(postUrl, options)
}
Author And Source
この問題について(スプレッドシートで特定の行列の値が特定の変更をされたらSlackに通知する), 我々は、より多くの情報をここで見つけました https://qiita.com/Cesaroshun/items/42e3af93259abceb8d38著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .