Looking for advice on how to write this better. Source is Google Sheets. I have another few IF ELSE statements so looking to consolidate code.
I also want another condition where if employed == "NO" && school == "NO" and Postcode does not match those listed it sends a separate email.
Code truncated to best address specific question.
if (status == "" && postcode == "4518" || postcode == "4519" || postcode == "4550" || postcode == "4551" || postcode == "4552" || postcode == "4575" && employed == "NO" && school == "NO") {
MailApp.sendEmail(
// to email 1
}
);
}
else if (status == "" && postcode == "4556" || postcode == "4557" || postcode == "4558" || postcode == "4564" && employed == "NO" && school == "NO") {
MailApp.sendEmail(
// to email 2
}
);
}
}
I could potentially have a second dataset with two columns, Postcode and Email Address. Where a postcode MATCH is found it sends off to the email address listed in Column B. If no match found and employed == "NO" && school == "NO" then a fallback email is sent. No idea how to write that nor how to start researching that.
postcode in ["4518", "4519", "4550",...]- Robin Gertenbachpostcode == "4518" || postcode == "4519"form. Its live now so I am reluctant to go back and test. I'll do so on the next project and hopefully your suggestion helps someone else. Cheers. - BusyChild