# Google sheets "watch changes" workaround

**URL:** <https://community.make.com/t/google-sheets-watch-changes-workaround/67787>\
**Category:** Questions\
**Tags:** custom-apps, javascript, google-sheets, api, webhooks, connections\
**Created:** [January 29, 2025, 2:09pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787 "2025-01-29T14:09:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shay\_zinger](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Shay\_zinger](https://community.make.com/u/Shay_zinger)\
**Post date:** [January 29, 2025, 2:09pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/1 "2025-01-29T14:09:27Z")

</div>

**Issue Summary:**

I’m using a **Next.js 15 app** that updates a **Google Sheet via the Google Sheets API**. I have a **[Make.com](http://Make.com) webhook** set up to detect new data, but it only triggers when I manually edit the sheet. However, when my Next.js app updates the sheet via the API, the webhook does not receive any data.

**What I’ve Tried:**

- Confirmed that the API updates the sheet successfully.
- Checked that the [Make.com](http://Make.com) webhook works for manual edits.
- Verified that the webhook is set to detect new/updated rows.

So i would like to work on a workaround for this, using a regular webhook trigger (Instead of the “Watch Changes” module) and a Apps Script around the “onChange” Trigger.

This guy seems to have figured the problem out, and has made a workaround for it on the google apps script platform. i would love to copy their workaround script, but i cant communicate with them. ----\> [nick\_cph](https://community.make.com/t/watch-changes-on-google-sheet-not-triggering-on-new-row-added/23910/13)

---

<div class="post-metadata">

**Author:** ![kudracha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/kudracha/32/61210_2.png) [@kudracha](https://community.make.com/u/kudracha)\
**Post date:** [January 29, 2025, 2:19pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/2 "2025-01-29T14:19:13Z")

</div>

Hi @Shay_zinger, I can confirm that watch changes only works on user-entered edits. If you know that onChange will work, it’s fairly simple. You’ll have to create a script like this :

```auto
function onChange(e) {
  var url = "https://hook.eu1.make.com/YOUR_WEBHOOK";
  
  // Prepare the payload if needed (you can customize the data you want to send)
  var payload = {
    "key1": "true",
    "key2": "value2"
  };
  
  // Set up the options for the HTTP POST request
  var options = {
    "method": "post",
    "contentType": "application/json",
    "payload": JSON.stringify(payload)
  };
  
  // Send the request to the webhook
  var response = UrlFetchApp.fetch(url, options);
  
  // Log the response (optional)
  Logger.log(response.getContentText());
}

```

Then go in ‘triggers’ on left sidebar and ‘add a trigger’. choose the function onChange() and in the end choose Trigger on change in the menu. Don’t forget to put your webhook link in this script. That should be it.

Mention me if you have more questions.  
kud

---

<div class="post-metadata">

**Author:** ![Shay\_zinger](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Shay\_zinger](https://community.make.com/u/Shay_zinger)\
**Post date:** [January 29, 2025, 2:34pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/3 "2025-01-29T14:34:47Z")

</div>

It works! thank you very much  
Do you know how to specify a range of cells for it to trigger the script?

---

<div class="post-metadata">

**Author:** ![kudracha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/kudracha/32/61210_2.png) [@kudracha](https://community.make.com/u/kudracha)\
**Post date:** [January 29, 2025, 2:52pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/4 "2025-01-29T14:52:18Z")

</div>

@Shay_zinger, Emm you can get range of where the (e) event happened and do if-else condition like this :

```auto
var sheetTarget = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MY SHEET NAME");
var currentSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

if (currentSheet != sheetTarget) {return}

const rangeTarget = "MY TARGET RANGE IN A1:B2 FORMAT"
if (e.changeType === "EDIT") {
    const range = e.source.getActiveRange();
    if (!isRangeInsideAnother(range, rangeTarget)){return}
}
else {return}

```

To be inserted just before “var url = “…”;”

* * *

This is what chatGPT offers to check if range is in another range :

```auto
function isRangeInsideAnother(range, rangeTarget) {
  // Get start and end row/column for range
  var startRow1 = range.getRow();
  var startCol1 = range.getColumn();
  var endRow1 = startRow1 + range.getNumRows() - 1;
  var endCol1 = startCol1 + range.getNumColumns() - 1;

  // Get start and end row/column for rangeTarget
  var startRow2 = rangeTarget.getRow();
  var startCol2 = rangeTarget.getColumn();
  var endRow2 = startRow2 + rangeTarget.getNumRows() - 1;
  var endCol2 = startCol2 + rangeTarget.getNumColumns() - 1;

  // Check if range is completely within rangeTarget
  return (
    startRow1 >= startRow2 && endRow1 <= endRow2 &&
    startCol1 >= startCol2 && endCol1 <= endCol2
  );
}

```

P.S. It might not work because onChange(e) usually does not return a range… onEdit(e) does this. Mention me if u have more questions

---

<div class="post-metadata">

**Author:** ![Shay\_zinger](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Shay\_zinger](https://community.make.com/u/Shay_zinger)\
**Post date:** [January 29, 2025, 3:23pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/5 "2025-01-29T15:23:29Z")

</div>

I added the range detection logic you suggested and now the script doesnt run on change. any idea how to fix it?

```auto
function onChange(e) {

var sheetTarget = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var currentSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

if (currentSheet != sheetTarget) {return}

const rangeTarget = "C2:C380000"
if (e.changeType === "EDIT") {
    const range = e.source.getActiveRange();
    if (!isRangeInsideAnother(range, rangeTarget)){return}
}
else {return}

  var url = "https://hook.eu2.make.com/(mywebhook)";
  
  // Prepare the payload if needed (you can customize the data you want to send)
  var payload = {
    "key1": "true",
    "key2": "value2"
  };
  
  // Set up the options for the HTTP POST request
  var options = {
    "method": "post",
    "contentType": "application/json",
    "payload": JSON.stringify(payload)
  };
  
  // Send the request to the webhook
  var response = UrlFetchApp.fetch(url, options);
  
  // Log the response (optional)
  Logger.log(response.getContentText());
}

```

---

<div class="post-metadata">

**Author:** ![kudracha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/kudracha/32/61210_2.png) [@kudracha](https://community.make.com/u/kudracha)\
**Post date:** [January 29, 2025, 3:55pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/6 "2025-01-29T15:55:16Z")

</div>

@Shay_zinger, For this use case we could just look if column is C, instead of using advanced range-matching function. It has to be tested and will take some time.

Try this :

```auto
function onChange(e) {

var sheetTarget = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var currentSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

if (currentSheet != sheetTarget) {Logger.log("not the same sheet");return}

if (e.changeType === "EDIT") {
    var firstColumn = range.getColumn();
    var numColumns = range.getNumColumns(); 
    var columnTarget = 3; // Column C

    // Check if column C is within the edited range
    if (firstColumn > columnTarget || columnTarget-firstColumn >= numColumns) {
        Logger.log("column C is not changed");
        return
    }
}
else {Logger.log("not edit");return}

  var url = "https://hook.eu2.make.com/1z5imh6qd7oo42jg5itmn616ox8qtnbt";
  
  // Prepare the payload if needed (you can customize the data you want to send)
  var payload = {
    "key1": "true",
    "key2": "value2"
  };
  
  // Set up the options for the HTTP POST request
  var options = {
    "method": "post",
    "contentType": "application/json",
    "payload": JSON.stringify(payload)
  };
  
  // Send the request to the webhook
  var response = UrlFetchApp.fetch(url, options);
  
  // Log the response (optional)
  Logger.log(response.getContentText());
}

```

Look in ‘executions’ tab in apps script to look at Logs if there are any.

---

<div class="post-metadata">

**Author:** ![Joe\_Donoghue](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Joe\_Donoghue](https://community.make.com/u/Joe_Donoghue)\
**Post date:** [February 2, 2025, 10:41pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/7 "2025-02-02T22:41:35Z")

</div>

I’ve encountered the same problem here.

I’m unsure on how to setup next.js 15 and run this script, can you offer any help?

---

<div class="post-metadata">

**Author:** ![Joe\_Donoghue](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Joe\_Donoghue](https://community.make.com/u/Joe_Donoghue)\
**Post date:** [February 3, 2025, 12:49am UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/8 "2025-02-03T00:49:31Z")

</div>

@Shay_zinger

Hi, have you managed to get this working? I could really do with your help.

@kudracha  
how do I edit the payload so that it pulls the ‘name’ and ‘phonenumber’ fields from the sheet?

 ![Screenshot 2025-02-03 at 00.48.32](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/d/b/dba4b43257fb196466c6f054489a770de5b891d8.png)

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [February 12, 2025, 3:00pm UTC](https://community.make.com/t/google-sheets-watch-changes-workaround/67787/9 "2025-02-12T15:00:42Z")

</div>


