BCC email notification from parm1

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2024 05:43 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2024 06:23 PM
@Moedeb you need to use email script for this. Please refer below example
// 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());
}
}
And in email notification body you need to call email script. below is syntax.
${mail_script:scriptName}
Please mark my answer correct and helpful if this works for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2024 11:09 PM
@Gangadhar Ravi so that sort of worked - it sends to the recipient list as a BCC, but the notification is also sent to the to list, so it is ultimately generating 2 notifications for each person.
I tried unselecting 'event parm 1' from the Who will receive on the notification, then it didn't send to anyone at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2024 09:56 PM
Hi @Moedeb
You can refer below post to get the logic :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2024 11:40 PM
Hello,
To handle a situation where you want to send a notification to a dynamic list of recipients using a parm1
parameter but place all recipients in the BCC field rather than the "To" field, you will need to customize the notification script to manipulate the email headers accordingly. Here’s how you can approach this in a script:
-
Create or Update the Notification Script: You need to use a script to customize the behavior of your notification. Since you want to use
parm1
for the recipient list and place all of them in the BCC field, you’ll need to modify the notification’s email sending logic. -
Sample Script for Notification: Below is a sample script that shows how you might achieve this in a notification script. This script assumes that
parm1
contains a comma-separated list of email addresses.// Notification script
(function sendNotification() { var recipients = current.event.parm1; // Retrieve recipient list from parm1 // Ensure recipients are in a format we can use var recipientList = recipients.split(','); // Split by comma to handle multiple recipients // Create email message object var mail = new GlideEmailOutbound(); // Set email subject and body mail.setSubject('Your Notification Subject'); mail.setBody('Your Notification Body'); // Set BCC field mail.setBcc(recipients); // Send email mail.send(); })();
- Explanation:
current.event.parm1
retrieves the dynamic recipient list.recipients.split(',')
splits the comma-separated list into an array of email addresses.mail.setBcc(recipients)
sets all addresses to the BCC field.mail.send()
sends the email
- Explanation:
Regards,
Vaishnavi Lathkar