0

https://support.google.com/docs/answer/91588?hl=en

I have a Sheet where the the cells are filled in with data that is pulled via Apps Script, which they get from a website. Sometimes they pull in the exact same data, sometimes not. On the old Sheets version I use to be able to get emails when the data only "changes" to a different value. Now with the new Sheets, I get an email when new data is pasted into the cells, even though its the exact same data......and, I can't set it to look at ranges anymore, only the entire document. Is there an easy way to watch cells for when the data changes, and then email myself?

Serge insas
  • 45,904
  • 7
  • 105
  • 131
Aaron
  • 3,135
  • 20
  • 51
  • 78
  • Have you tried including an email function in your onEdit()? Please let us know if you've made any attempts on this so far. – pointNclick May 14 '15 at 18:37
  • I haven't. Not real good with it yet, here's my sheet tho: https://docs.google.com/spreadsheets/d/12BBrYvDiPHhmy11dcWmqpGV065gihQy75Tspx-UfnAE/edit#gid=0 – Aaron May 14 '15 at 22:09
  • 1
    Read the links I provided in the answer below. They should help you out. They're exactly what you need. Then if you get stuck, create a new question, post your code and we can help you resolve it further. – pointNclick May 14 '15 at 23:10

1 Answers1

1

This looks a lot like what you're trying to do.

For checking whether the value has truly changed after the edit, this gives you all the necessary information about it. Hence, you would know whether the new value is the same one or not. Implementing the "workaround" talked about in the second link, I was able to compare and send an email to myself if the value changed. Initiate an onEdit trigger that goes off for your onEdit function which uses these lines after all the checks in place have passed.

var email = "xyz@whatever.com";
MailApp.sendEmail(email, "TriggerMail", "A change has occurred in the Sheet");

NOTE: This only sends you a "notification" sort of an email but you can even include the changed values in the email easily by just following this tutorial.

Community
  • 1
  • 1
pointNclick
  • 1,584
  • 1
  • 12
  • 17
  • I was thinking of copying the data to another sheet, then pulling new data, and comparing it at the end. I think I have all of it down except how to compare it, and to email if there's any difference... – Aaron May 15 '15 at 02:23
  • Have your onOpen function copy the data to the other sheet. This will ensure your data in the other sheet is up-to-date before anyone changes anything in the sheet. When any change is made, get the range for the changes made by using [e.range](https://developers.google.com/apps-script/guides/triggers/events#google_sheets_events). Get the values in the other sheet for the same range and compare them. However, you will have to come up with a strategy for the scenario where rows are inserted in your sheet. That might be a basis for a new question on it's own. – pointNclick May 15 '15 at 16:41