'Copy Paste not working in onEdit function in Google App Script
I have a Google App script that needs to return the changes made to the Spreadsheet and return it to slack. The script is failing whenever there is a copy paste done inside the Spreadsheet on the file (Either multiple rows or columns are copied together or a single entry) both are not working. This is my current script:---
**var url ="Slack Webhook URL";
function sendSlackNotification(e) {
var newValue = e.value;
var oldValue = e.oldValue;
var user = e.user;
var row = e.range.getRow();
var spreadsheetName = SpreadsheetApp.getActiveSheet().getName();
var payload = {
'text' : user + " just changed from oldValue : '" + oldValue + "' to newValue : '" + newValue + "' at row : '" + row + "' in the following Sheet : " + spreadsheetName +" :grimacing:"
};
var params = {
'method' : 'post',
'contentType' : 'application/json',
'payload' : JSON.stringify(payload)
};
return UrlFetchApp.fetch(url, params)
}**
Need to fix Copy Paste Functionality while performing onEdit function in Spreadsheet
Solution 1:[1]
When using onEdit triggers, value and oldValue only appear on single cells; try adding Logger.log(JSON.stringify(e)) in your function and check your execution logs to see what the event object structure looks like.
You will most likely have to modify your function to check whether range.columnStart/range.columnEnd and range.rowStart/range.rowEnd are equal to determine if it's a range being edited or a cell and take it from there.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | NEWAZA |
