BCC email notification from parm1

Moedeb
Tera Guru

I am wanting to send a notification out to a changing list of recipients, I already have that handled in a flow that ultimately fires an event that contains the recipient list, however it is adding those from parm1 into the 'To' field of the notification and I'd like it to not add anyone to the 'To' field and instead add them to the 'BCC'

 

I know that if I have a set list I can add the users via a mail script, however I'm not aware of how to handle it when I want to use parm1 instead of a particular user.

 

Anyone able to assist please?

11 REPLIES 11

@Vaishnavi Lathk do you mean mail script?

 

Or does this script go in the actual notification somewhere?

Moedeb
Tera Guru

So thanks to @Gangadhar Ravi I have the following mail script, that sort of works, but there are issues still:

Script name is: 

BCC.parm1.script

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

    // Add your code here
// Get the recipients list from parm1
var recipients = event.parm1; 

if (recipients) {
    // Convert parm1 to an array (in case it's comma-separated)
    var recipientArray = recipients.split(',');

    // Add each recipient to the BCC list
    for (var i = 0; i < recipientArray.length; i++) {
        email.addAddress("bcc", recipientArray[i].trim());
    }
}
})(current, template, email, email_action, event);

 

In the notification body I have called the mail script with:

${mail_script:BCC.parm1.script}

 

Scenario 1:

Notification "Who will receive" has Event parm1 contains recipient selected.

Result - Notification is sent twice - once to all in the To field and again to same people in the BCC field.

 

Scenario 2:

Notification "Who will receive" has nothing at all selected.

Result - No notification sent at all

 

Scenario 3:

Notification "Who will receive" has myself added as a recipient.

Result - Multiple notifications are sent, but no one shows for all but one of the in the To, CC or BCC fields and an error is available:

"System address filter excluded email addresses (Missing final '@domain'): c23a5620c942e550bdae5d1ef478d5e8, 1c57fdb8900c7590662da657ee3b1d68, etc"

 

Looks like it is not getting emails from the user sys_id's

 

Hello,

 

You can add in your event a blank email,

gs.eventQueue("sn_customerservice.OutageStartNotificati", current, "email@noreply.com", bccString);
 
And in your email notification check the box event_parm1
 
In some ways I had the same issue, the platform send notification in bcc + recipients like your first scenario

@MakeYourLife thank you for the reply however I don't really understand what I need to with those instructions, would you be able to be a little more specific?

Hello @Moedeb ,

 

I had the same issue than your scenario1, Here is what I did, I hope it helps : 

 

- I have a business rule that triggers whenever a record is created, I retrieve a list of users and get the emails, when I call the event to trigger the notification I added in the event parameter 1 

 

example:

gs.eventQueue('event.name', GlideRecord, parm1, parm2); // standard form

gs.eventQueue('x_58872_needit.overdueNeedItTask',current,"email@noreply.com", bccString);

=> In bccString you have the dynamic emails

 

Then in my email notification I check the event_parm_1

MakeYourLife_0-1744868485302.png

This should avoid sending to "To" recipients, and only in bcc but it seems we must have a recipient in "To" that is why I setted it as a blank "noreply" email