I have already code in apps script and would like to add Timestamp function in the same google sheet, using Apps Script.
Whenever users encode B column,
Timestamp in A column should be encoded Automatically by Appls Script.
I will show my current code in the file, as below.
Let me know how and which code I should add.
Thank you in advance.
<code>const WEBHOOK_URL = 'I encoded here my Slack channel webhook url';
function sendSlackNotification(sheetName, cell, value) {
var message = `Sheet: ${sheetName}n Cell: ${cell}n New Value: ${value}n==========================`;
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.getValues()[0];
sendSlackNotification(sheetName, cell, value);
}
</code>
<code>const WEBHOOK_URL = 'I encoded here my Slack channel webhook url';
function sendSlackNotification(sheetName, cell, value) {
var message = `Sheet: ${sheetName}n Cell: ${cell}n New Value: ${value}n==========================`;
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.getValues()[0];
sendSlackNotification(sheetName, cell, value);
}
</code>
const WEBHOOK_URL = 'I encoded here my Slack channel webhook url';
function sendSlackNotification(sheetName, cell, value) {
var message = `Sheet: ${sheetName}n Cell: ${cell}n New Value: ${value}n==========================`;
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.getValues()[0];
sendSlackNotification(sheetName, cell, value);
}
New contributor
Kiwi juice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.