- 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-16-2021 11:59 PM
Hello Ashwini,
As Mahesh suggested already, you can select those recipients in the notification. If its not empty, then SN will send mail otherwise it will not.
If the notifcation is not on the same table where these fields present, then you have to write mail script and fetch the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 03:13 AM
Yes Asif,
I tried both the ways by adding event also, still not working, Its sending notification only to the secondary email id. Can you please suggest any other ways.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 03:41 AM
Hello Aswini
Here are ways to debug
1. Can you to go system mailboxes->outbound->sent and check if the mail is there. if yes open that and check if you see TO and cc field filled with 1 or 2 email addresses?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 04:18 AM
In recipent list its showing only primary mail id, not the secondary mail id. I am not getting TO and CC option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 04:54 AM
Hi Asif,
Actually the notification is written on incident table and email id fields are present in User table. So in this case can you please suggest how can i write mail script?