I made a webpage vis Softr. If my customers encode something in the webpage, it will be encoded in Google sheet.
Whenever there are changes in google sheet, I’d like to get the messages in Slack.
I made it w/ Apps Script and could get messages in Slack but it does NOT SHOW VALUES in the celles as below.
Slack Message :
Sheet: Sheet1, Cell: A130:F130, New Value:
If you know about this, please help me how I can change this cording.
Thank you.
const WEBHOOK_URL = *'I encoded here the webhookurl of my slack channel'*; // 여기에 생성한 Webhook URL을 입력하세요.
function sendSlackNotification(sheetName, cell, value) {
var message = `Sheet: ${sheetName}, Cell: ${cell}, New Value: ${value}`;
Logger.log(message); // 디버깅을 위해 로그에 기록
// 슬랙에 알림 보내기
var payload = {
text: message
};
var options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(payload)
};
UrlFetchApp.fetch(WEBHOOK_URL, options);
}
function onChange(e) {
var sheet = e.source.getActiveSheet();
var sheetName = sheet.getName();
// 변경된 범위를 가져오기 위해 마지막 편집 시간을 이용
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
var range = sheet.getRange(lastRow, 1, 1, lastColumn);
var cell = range.getA1Notation();
var value = range.getValue();
sendSlackNotification(sheetName, cell, value);
}
Kiwi juice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.