Dynamically adding To values on Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 12:53 PM
I have a requirement which states that email are set to Program Manager which projects are associated to custom form (Meeting Review Form). The notification is configured to be sent when the attachment event is triggered. My issues is to dynamically populate to To value via script. The Wiki shows how to set the below but not the To value.
The only way I can see to do it would be to update the Business Rule that triggered the attachment event (Global), added a business rule to my custom table to trigger a event and pass the user in Parm1. I don't want to modify the OOB attachment event business rule. Is there a way via the notification script that I don't see?
...
email.setFrom(current.caller_id.email);
email.setReplyTo("joe.employee@yourcompany.com");
email.setSubject("This is the new subject line");
email.setBody("This is the new body");
.
email.addAddress("cc", "john.copy@example.com","John Roberts");
email.addAddress("bcc", "john.secret@example.com","John Roberts");
Thank you for your assistance is advanced.
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 01:38 PM
What I might do instead is create a new event and leverage that in your notification. Please explain which table the notification resides in as well as what the code you are currently using so that we can focus our solution accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 02:03 PM
OOB the sys_attachment table triggers the attachment.uploaded event upon loading a new attachment. The business rule that triggers that event can be modified so that event isn't triggered for my custom table.
I can then create a different business rule that triggers the new or same event but with a dynamic list of users in Parm1. Do don't want to modify this OOB Business rule. I am looking for a differ option.
In the Wiki, below are email script variable that can be used to set email attributes in a notification definition. But what I don't see is a variable to dynamically update the email To attribute. Is there a way to set the To email attribute via the email script.
email.setReplyTo("joe.employee@yourcompany.com<mailto:joe.employee@yourcompany.com>");
email.setSubject("This is the new subject line");
email.setBody("This is the new body");
.
email.addAddress("cc", "john.copy@example.com<mailto:john.copy@example.com>","John Roberts");
email.addAddress("bcc", "john.secret@example.com<mailto:john.secret@example.com>","John Roberts");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 02:24 PM
I think you are getting the ability to send to multiple recipients using an event parameter confused with setting custom headers. I would take a look at the following Wiki article instead:
Events and Email Notification - ServiceNow Wiki
That should give you a clue as to what to do to send to multiple recipients.
What is your current custom business rule look like? I would probably have it trigger a custom event that is on your custom table based upon when the attachment is added to that table record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 02:38 PM
The event triggered for adding an attachment to a record is OOB and I don't want to modify it. Let's put that assign for 1 second.
I would like to set the "To" value on my emails via the notification scripts. There are variables to set the cc and bcc values (see below). Is there a way to set the "To" value via script?
email.addAddress("cc", "john.copy@example.com<mailto:john.copy@example.com>","John Roberts");
email.addAddress("bcc", "john.secret@example.com<mailto:john.secret@example.com>","John Roberts");