- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2021 11:25 PM
Hi All,
We have a requirement that when a notification is sent, suppose a user has 2 mail id's. then it should send the notification to both the email address.
In user form we have below fields, suppose alternative email id field is not empty then it should send notification to both the email id's. Please suggest some solution to implement this.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 05:59 AM
Create a business rule on sys_email before insert that adds each recipient's alternate email address to the Recipients field.
(function executeRule(current, previous /*null when async*/) {
// get the current recipient(s)
var emailTo = current.recipients.split(',');
for (var i = 0; i < emailTo.length; i++) {
// look for a user matching a recipient email address
var userRec = new GlideRecord('sys_user');
userRec.addEncodedQuery('email=' + emailTo[i] + '^u_alternate_emailISNOTEMPTY');
userRec.query();
if (userRec.next()) {
// found one, so add their alternate email
emailTo.push(userRec.u_alternate_email);
}
}
// save the recipients
current.recipients = emailTo.join(',');
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 06:09 AM
Okay.
So in the mail script, assuming you want to fetch the assigned_to user primary and alternate meails.. do like this
1. In place of assigned_to, put your field. and also use right field names of your priamry and alternate email.
email.addAddress("cc",current.assigned_to.primary_email,current.assigned_to.getDisplayValue());
email.addAddress("cc",current.assigned_to.alternate_email,current.assigned_to.getDisplayValue());
and call this mail script in your notification
${mail_script:your_mailscript_name}
2. In the notifcation, under receipients, ensure you select atleast 1 recipient.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 11:23 PM
Hi Asif,
Yes I tried this method. I selected my name and i have 2 email id's. There is also 1 group we added. Still the code is not working its sending only to primary email id. I am not getting what is the reason its not triggering. Can you please suggest

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 11:53 PM
Hi,
can you share yoru notification screenshots.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 05:38 AM
Hi Ashwini,
Here my caller have two email address field 1)email 2)alternate email.
so configured as below and notification gets triggering to both email ID.
Please find the below link it will help to add CC and BCC.
I hope it helps,
Thanks,
Hemant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 11:25 PM