I am new in javascript and still learning. I had made a Spread Sheet as a tracker of work data with multiple users working on it. WorkArea tabWorkArea is where we tag the time and if completed. Another tab is the Error Tab ErrorTAB is a query tab and shows envelope number if tagged incorrectly (no time input and was tagged completed). In the error tab there is a counta formula on cell "S3" which will determine if there an error and will show "TRUE". My problem is that my code is sending too many emails every time users make an edit. If possible, I want it to send email once. Can you help me on this?
Here is the code I made with onEdit trigger
function sendEmail(e) {
var sp = PropertiesService.getScriptProperties();
var errorTab = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Error');
var cellRef = errorTab.getRange('S3').getValue();
var dataRef = "Kindly Check " + errorTab.getRange('B3').getValue() + errorTab.getRange('H3').getValue() + errorTab.getRange('N3').getValue();
var oldValue = sp.getProperty('S3') || 0;
if(cellRef == false && cellRef == oldValue) return;
else
var option = {
cc: "admin1@gmail.com",
}
{GmailApp.sendEmail("admin@gmail.com",
"Dating Contracts Email Notification for Error Tab",
dataRef,option);
sp.getProperty('S3', cellRef);
}
}