I have about 10 Google Scripts that send emails out when a form is submitted. It was working fine until recently, but suddenly all of them have started sending out two emails for any form submit. I've looked at the Execution Log and there are always 3 seconds between the first and second execution (the scripts only take about 1.5 seconds each to run).
I tried using a script lock (a solution I found on here) but so far, have not been able to stop the duplicate emails. I'm not sure if I did it correctly.
SpreadsheetApp.flush();
var lock = LockService.getScriptLock();
try {
lock.waitLock(500);
} catch (e) {
Logger.log('Could not obtain lock after 30 seconds.');
}
function sendEmails() {
---rest of the code---