How to configure one email with different set of conditions and different recipients as ext id's

Akhila23
Tera Contributor

Hi All,

I have a requirement to consolidate the count of notifications 127 into one notification , which has different set of conditions(when to send) and different recipients(whom to send) tagged external id's and common body content for all.

How to achieve this requirement and what would be the approach to implement this.

 

I have tried creating the email script to implement this , but this is not working


(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {


var emails = new GlideRecord('sys_email');
emails.addQuery('your_criteria', 'your_value');
emails.query();
var mergedSubject = "Merged Subject";
var mergedBody = "";
while (emails.next()) {
mergedBody += emails.body_text + "\n\n"; // Assuming body_text is the field containing email body
}
var mergedEmail = new GlideEmailOutbound();
mergedEmail.addAddress("recipient@example.com"); // Set recipients
mergedEmail.setSubject(mergedSubject); // Set subject
mergedEmail.setBody(mergedBody); // Set merged body
mergedEmail.send();

})(current, template, email, email_action, event); 

 

i tried using advanced condition builder in notification condition , but i am not able to satisfy the recipient list

 

can someone please help on how to achieve this , merging all emails into one.

 

1 REPLY 1

Akhila23
Tera Contributor

Can some really help me on this