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?
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] 삭제
몇 마디 만하겠습니다