Google Apps Script to send an email stating which value replaced which value in a given cell in Google Sheets

CODEBLACK

I've been trying to twist my brain around designing something that will send me an email if the contents of a specific cell are overwritten.

So say you have cell A1. I write the name of a color (e.g. red) in that cell. Now if someone else comes and overwrites my color with a different color (e.g. blue), I want to receive an email stating that the contents of cell A1 was overwritten and that red is now blue.

Below is a simple onEdit trigger. I can make it send emails with the newly added value. However, I don't know how to grab the previous value before it is overwritten. I assume this is because the script is triggered after the value has already been changed.

function onEdit(e){ 

  var range = e.range;
  var newValue = range.getValue();

  MailApp.sendEmail('my email', 'value was overwritten', 'old value:' + previousValue + ' new value:' + newValue + new Data());
}

Any ideas?

HDCerberus

Unfortunately, this is not currently possible at this time. There's an open enhancement request for it, so if you're interested, I would recommend staring it (and getting anyone else interested to star it also) for traction.

The only option you've have for this kind of feature would be to copy the sheet data to a 'backup' sheet with an 'OnOpen' trigger, and compare the cells when a change is made, but this is quite a lot of work, so I guess you need to think carefully about if it would be worth it.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Passing selected value of a listbox to another listbox in google-apps-script

분류에서Dev

Google Spreedsheets Apps Script-On Cell Focus

분류에서Dev

which value does javascript function takes if the function is called in the given example?

분류에서Dev

Adjust file created date value for date between evaluation using Google Apps Script

분류에서Dev

Google Sheets looking for a google script like VLOOKUP but combines the found values and joins them into a specific cell

분류에서Dev

Need assistance changing cell values in a google sheets script to match another cell

분류에서Dev

MVC - Getting Textbox value which is set by jQuery script

분류에서Dev

Google spreadsheet formula which takes its cell range values from other cell?

분류에서Dev

Google-apps-script SyntaxError

분류에서Dev

Google Apps Script 호출

분류에서Dev

Invalid value for ByteString for Update photo in Google Apps engine in java

분류에서Dev

Is it possible to know if a domain is using Google Apps for email?

분류에서Dev

Apps Script의 Google Docs API

분류에서Dev

Google 양식 + Apps Script onEdit

분류에서Dev

Are there restrictions on using UrlFetchApp with Triggers in Google Apps Script

분류에서Dev

Google Apps Script 잘못된 값

분류에서Dev

Google Apps Script와 Firebase 통신

분류에서Dev

$(li).width() returning value which includes padding?

분류에서Dev

BufferedReader reads a value which is somehow null

분류에서Dev

Sum value from fields which are in one row

분류에서Dev

Initialize variable as function which return value

분류에서Dev

Google Sheets code to move the active cell in the onOpen event?

분류에서Dev

How to render Google Pay button in Google Apps Script

분류에서Dev

Excel VBA - Copy cells between sheets if cell value satisfies criteria

분류에서Dev

which package replaced the libzimg-dev?

분류에서Dev

Google Sheets API V4 및 Google Apps 스크립트

분류에서Dev

Google Sheets Apps Script를 사용하여 전송 된 데이터의 로그 탭 만들기

분류에서Dev

Google Sheets + Apps Script : 셀 값을 기준으로 이름으로 시트를 삭제하는 방법

분류에서Dev

What is a good way to call a python script from a Google Sheets spreadsheet?

Related 관련 기사

  1. 1

    Passing selected value of a listbox to another listbox in google-apps-script

  2. 2

    Google Spreedsheets Apps Script-On Cell Focus

  3. 3

    which value does javascript function takes if the function is called in the given example?

  4. 4

    Adjust file created date value for date between evaluation using Google Apps Script

  5. 5

    Google Sheets looking for a google script like VLOOKUP but combines the found values and joins them into a specific cell

  6. 6

    Need assistance changing cell values in a google sheets script to match another cell

  7. 7

    MVC - Getting Textbox value which is set by jQuery script

  8. 8

    Google spreadsheet formula which takes its cell range values from other cell?

  9. 9

    Google-apps-script SyntaxError

  10. 10

    Google Apps Script 호출

  11. 11

    Invalid value for ByteString for Update photo in Google Apps engine in java

  12. 12

    Is it possible to know if a domain is using Google Apps for email?

  13. 13

    Apps Script의 Google Docs API

  14. 14

    Google 양식 + Apps Script onEdit

  15. 15

    Are there restrictions on using UrlFetchApp with Triggers in Google Apps Script

  16. 16

    Google Apps Script 잘못된 값

  17. 17

    Google Apps Script와 Firebase 통신

  18. 18

    $(li).width() returning value which includes padding?

  19. 19

    BufferedReader reads a value which is somehow null

  20. 20

    Sum value from fields which are in one row

  21. 21

    Initialize variable as function which return value

  22. 22

    Google Sheets code to move the active cell in the onOpen event?

  23. 23

    How to render Google Pay button in Google Apps Script

  24. 24

    Excel VBA - Copy cells between sheets if cell value satisfies criteria

  25. 25

    which package replaced the libzimg-dev?

  26. 26

    Google Sheets API V4 및 Google Apps 스크립트

  27. 27

    Google Sheets Apps Script를 사용하여 전송 된 데이터의 로그 탭 만들기

  28. 28

    Google Sheets + Apps Script : 셀 값을 기준으로 이름으로 시트를 삭제하는 방법

  29. 29

    What is a good way to call a python script from a Google Sheets spreadsheet?

뜨겁다태그

보관