Reputation: 1
I am trying to receive an email whenever some changes happen to my google doc. I know that there is a trigger on it for google sheets, but I don't know how to do something like that in docs. I saw in this post Google Docs Add On onEdit that it might be possible to get an update every 60s, but couldn't figure out how it would send email?
MailApp.sendEmail('[email protected]','new edit')
I tried adding this code instead of callyourfunction(), bur nothing happened.
Update: Sorry I'm a beginner in Java and GAS, this is how far I got with the code:
function addTimeStamp(e){
var row= e.range.getRow();
var col= e.range.getColumn();
if (col===1 && row >1 && e.source.getActiveSheet().getName()=== "Sheet1"){
var currentDate=new Date();
e.source.getActiveSheet().getRange(row,4).setValue(currentDate);
if( e.source.getActiveSheet().getRange(row,3).getValue()==""){
e.source.getActiveSheet().getRange(row,3).setValue(currentDate);
}
}
}
so it would update the date in the 4th-row cell if changes happen to row 1. But What I want is to check the mentioned google docs ID in the first row and inform me of any changes that happen to that document.
Upvotes: 0
Views: 259
Reputation: 1429
Here is the documentation for onEdit()
.
Depending on the number of documents you want to monitor, I would likely suggest the following alternative approach:
In regards to 1, create a Table with the following headers:
In regards to 2, add 3 Google Doc Ids, one in each row
In regards to 3, see here for how to get Sheets Data the last updated date
Upvotes: 1