Here are some comments and suggestions:
If emails are being sent again to some folks, then the email sent flag is probably being put in the wrong place. Looking at the statement that sets the flag:
sheet.getRange(i + 2,10).setValue("Email Sent");
versus the statement that checks the flag:
var emailstatus = rowData [8];
tells me it seems to be setting the flag in the wrong column. The i+2 is correct because you are starting reading the array from row 2. But the 10 should be 9 to be set in the correct column.
For skipping blank rows, you should determine which cell you want to be based off of and check if that cell is blank then skip the row based on that. For example if the startdate is blank, then skip. Something like this:
If( (emailstatus != "Email Sent” ) && (startdate != “”) )
To Have your emailToGoogleAdmin function trigger automatically, just define a trigger that would trigger on change and in the function, check first to see if the change is to the checkbox column being set to true, if not, just ignore. This way only when checkbox is set to true would your function process the rest and send the email.
Add these to statements at the top of your function:
const col = e.range.getColumn();
If ( (col != 11) || (e.valu != “TRUE”) ){return;}
Good luck
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4ac80cbf-812e-4a86-899e-b89664dede85n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/639ffdaf-1b9b-4d89-8d5f-c388a0b3d0b4n%40googlegroups.com.
You have a typo in the IF statement:
if ( (col != 8) || (e.valu != "TRUE") )
This should be:
if ( (col != 8) || (e.value != "TRUE") )
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/857d05d4-6803-4acc-94cf-58335080032en%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/1fdc2b57-36ab-45a9-a407-e7f10e3c1554n%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/ZKzqJGkjPIU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/5468c422-d4d8-4d1e-9142-86d639286a8dn%40googlegroups.com.