# onEdit() script won't run when sheet is edited by Glide app

**URL:** <https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850>\
**Category:** Ask for Help\
**Created:** [May 10, 2020, 11:22am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850 "2020-05-10T11:22:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [May 10, 2020, 11:22am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/1 "2020-05-10T11:22:45Z")

</div>

I have written a google script with an `onEdit()` installable trigger function, the problem is that it won’t trigger when the sheet is edited via the glide app, it does however trigger successfully when I edit the sheet manually.

Has anyone come across this issue with google sheet scripts and glide apps?

@Jeff_Hager or @Mark any ideas why it wouldn’t trigger from an update via the glide app?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 10, 2020, 12:18pm UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/2 "2020-05-10T12:18:52Z")

</div>

Hi Rogelio,

As I have discussed here, `onEdit()` won’t work with Glide. Change it to `onChange()`, or trigger the event by an “on change” option in the triggers dashboard.

> [@Time stamp update](https://community.glideapps.com/t/time-stamp-update/1382/28):
>
> Hi, I would like to suggest you changing from onEdit to onChange and see what happens when you edit the checkboxes in Glide. This thread says: " onEdit only works when you edit a cell (not when a row is added or when a note/comment is added) and onChange will capture that a change has occurred and trigger when appropriate." As the Sheets may not have seen a Glide action as a “cell edit” action, onChange would suit better as it takes into account the value of the cell.

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [May 10, 2020, 12:28pm UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/3 "2020-05-10T12:28:14Z")

</div>

yep! - that worked!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 10, 2020, 12:30pm UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/4 "2020-05-10T12:30:31Z")

</div>

Nice to hear, have a nice day!

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [May 18, 2020, 12:39am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/5 "2020-05-18T00:39:42Z")

</div>

Follow-up question @ThinhDinh thought you may know…

my sheet’s `onChange` script works, but have noticed that it is constantly being executed even though there is no change to any of the sheets.

Have you come across this?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 18, 2020, 1:13am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/6 "2020-05-18T01:13:50Z")

</div>

Hi Rogelio,

It’s possible that other parts of the sheet are experiencing changes. onChange() is triggered for any changes in the sheet. Can you check that?

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [May 18, 2020, 1:24am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/7 "2020-05-18T01:24:55Z")

</div>

how can I check what actual change was made?

I have noticed that edits are being made even though I’m not touching the app or making any manual updates to any of the sheets. The label at the top of the sheet updates every now and then.

I have tried comparing the versions but no changes are coming up? could it possibly be that Glide is making some non-visible changes to the sheet in the background?

 ![Screen Shot 2020-05-18 at 10.51.32 am](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/f/ff04eccd37c42b94307dce2ae4ae8f0454af690d.png)

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 18, 2020, 1:27am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/8 "2020-05-18T01:27:22Z")

</div>

Send me a personal message of your script and possibly a copy of your sheet, I will take time to have a look.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 18, 2020, 2:20am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/9 "2020-05-18T02:20:34Z")

</div>

Do you have background refresh turned on in Glide? That will update a hidden metadata sheet every few minutes.

I’d also recommend an if statement at the beginning of your script to jump over the rest of the script if the current sheet is not the one you want to run the script against.

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [May 18, 2020, 3:07am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/10 "2020-05-18T03:07:01Z")

</div>

These are my Refresh settings, do you suggest changing it to ‘only on edit’?

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/1/1c8f9ef9d82bc4a1af7b4cfdec170f2bf47fd6c5.png)

I do have an `IF` statement, so the script skips any unnecessary updates/modifications, my only concern is that the script is constantly being triggered.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 19, 2020, 3:59am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/11 "2020-05-19T03:59:02Z")

</div>

onChange is triggered any time the spreadsheet is touched/changed on any sheet. Like I mentioned earlier, when using "While editing or using the app’’, glide will modify the hidden App: Metadata sheet periodically which would be enough to trigger the onChange event. That’s the whole point of the Reload Sheet function. It’s so any background scripts, functions like RAND or NOW() or ImportRange can run without any user intervention to get them to update. I have a script set up similar where it will run any time there is a change in the sheet or the background refresh is turned on, but I also have an if statement to only trigger for certain sheets. I wouldn’t worry about it much unless you are getting errors from google.

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [May 19, 2020, 4:01am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/12 "2020-05-19T04:01:30Z")

</div>

thanks, makes sense.

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [June 17, 2020, 12:28pm UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/13 "2020-06-17T12:28:22Z")

</div>

This was a helpful thread! In one of my apps, I can now send a text message to a customer whenever a restaurant marks an order as “Bring Prepared” or “Ready” using a choice component.

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [June 17, 2020, 10:36pm UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/14 "2020-06-17T22:36:05Z")

</div>

G’day @Robert_Petitto

I’d really like to see how you’re achieving the sending of the message. Would you mind elaborating and perhaps sharing the script?

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [June 17, 2020, 11:37pm UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/15 "2020-06-17T23:37:09Z")

</div>

I used this method to send SMS messages as emails:

> [@Free push notifications Workaround](https://community.glideapps.com/t/free-push-notifications-solved/6183):
>
> I have a solution for PUSH NOTIFICATIONS. It works with IOS and ANDROID. It is quick and has ZERO cost to everyone. You can do this in your google sheet or a separate sheet that is linked to your original (I used 4 linked sheets, I’ll explain later). 1st you setup on your sheet a variable or value you are wanting to trigger the notification. This data will need a VLOOKUP formula to link to the person you want notified’s phone number and phone carrier, so when the vlaue on the sheet is found usin…

The context is that Chefs will mark the status of the order. This updates column B of my “Orders” sheet.

 ![Screen Shot 2020-06-17 at 7.31.34 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/4/4744bafd2eabd5cc45fd156f991081831e721e11.png)

Columns G-I of this sheet contain the phonenumer@carrier information and a message. The message column (I) is a template that contains the order status and the name of the restaurant.

 ![Screen Shot 2020-06-17 at 7.34.17 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/f/f956d5ba78113ac8e63f756acee2bb589681a253.png)

I wanted to send an email (SMS message) when the status changes in Column B to either “Being Prepared” or to “Ready” (there are 4 possible statuses).

Here was the code I used:

```auto
// The column you want to check if something is entered.
var COLUMNTOCHECK = 2;
// Sheet you are working on
var SHEETNAME = 'Orders';

function sendEmails() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  //checks that we're on the correct sheet.
  if(sheet.getSheetName() == SHEETNAME) { 
    var selectedCell = ss.getActiveCell();
    var selectedRow = selectedCell.getRow();
    var dataRange = sheet.getRange(selectedRow, 7, 1, 3);
    var data = dataRange.getValues();
    //checks the column to ensure it is on the one we want to cause the date to appear.
    if(selectedCell.getColumn() == COLUMNTOCHECK) { 
       for (var i = 0; i < data.length; ++i) {
         var row = data[i];
         var emailAddress = row[0]; // First column
         if (emailAddress.match('@') === null){
           continue; // skip this iteration of the loop and go to the next one
         };  
         var message = row[2]; // Third column
         if (message.match('!') === null){
           continue; // skip this iteration of the loop and go to the next one
         };
         if (message.match('complete') !== null){
         continue; // skip this iteration of the loop and go to the next one
         }; 
         var subject = 'Potluck Order Status';
         MailApp.sendEmail(emailAddress, subject, message, {name:'Potluck', noReply: true});
         SpreadsheetApp.flush();
         
       }
      }
  }
}

```

Finally, had to create an onChange trigger since the spreadsheet doesn’t recognize Glide writes-to-sheets as onEdit triggers.

Works like a charm!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 18, 2020, 12:29am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/16 "2020-06-18T00:29:29Z")

</div>

Thank you Bob, was also thinking that this also has something to do with the number@carrier part but I can’t figure out what the format is for our carriers here in Vietnam lol, not that I have clients in my own country so far, just wanna explore.

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [June 18, 2020, 12:31am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/17 "2020-06-18T00:31:48Z")

</div>

thanks @Robert_Petitto this is awesome, unfortunately this is a paid additional service for the major carries here in Australia.

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [July 1, 2020, 12:59am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/18 "2020-07-01T00:59:47Z")

</div>

There are actually ways around that Rogelio. You see, this is almost the same exact way they send texts from phone to phone. You just need to find the correct @sending ending 🙂

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [July 14, 2020, 11:59am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/19 "2020-07-14T11:59:30Z")

</div>

hey @Drearystate any ideas on how i can find a way around to find a cost-free solution?

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [July 16, 2020, 5:50am UTC](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/20 "2020-07-16T05:50:13Z")

</div>

Hi,

looking at your script as I’m trying to implement something similar.

Where in your script do you actually do the check for “`Being Prepared`” or “`Ready`” for the status of the order?

[Next page](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850.md?page=2)
