'Google App Script unable to send notification only for specific sheet and previously empty cell
I'm new to Google Script and I'm trying to create this script that will send notification to the messenger app when there is a new request filled into a specific tab and column.
So the tab's name is "Additional Requests" and only when a cell in column B "Request Number" is filled, it will trigger the notification. It shouldn't trigger notification when a filled cell is edited.
I have managed to make the trigger only happening to column B. However, the trigger also happens when other tabs' column B is edited even when I have already specified the tab "Additional Requests" in the script. Additionally, it also trigger notification when the filled cell in column B is edited. May I know what has gone wrong in the script? I have searched through a lot of similar questions to find answers but none worked.
Thank you in advance!
function API() {
var cell = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Additional Requests").getCurrentCell();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Additional Requests");
var columnofCellEdited = cell.getColumn();
if ((sheet.getSheetName() === "Additional Requests") && (columnofCellEdited === 2)) {
if((cell.value !== null) && (cell.oldValue == null)) {
var payload = JSON.stringify({
"tag": "text",
"text": {
"content": "--",
"email_list": ["[email protected]"],
"at_all": false
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

