Mail Scripts and the email Object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2010 08:24 AM
I'm working on a complex email notification and I'm looking for information on the "email" object that's available from within mail_script tags. My immediate concern is updating/overriding the recipient list of the generated sys_email record. So far I've managed to dump the members/method names of the email object (instance of Java class EmailOutbound) and start cobbling together a little API for it. Unfortunately, it seems like many of the setter methods don't to do anything. Can someone shed light on the following methods, or direct me to the API for the class com.glide.notification.outbound.EmailOutbound? My hope is that I'm just passing in the wrong parameter types, since I'm guessing them. Thanks much.
addAddress()
setAddress()
setRecipients()
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2011 09:11 AM
I would like an answer to this question also. In my case I have an issue where when mulitple events associated with the generation of emails are raised in quick succession, e.g. by a user attempting to make a correction to the recipient list for an email, then a problem occurs. The user updates the field in the record, say a change task record, from where the email notification picks up its recipients, before the first event is processed. This means that the recipient added last receives two emails and the first recipient receives none. I've tried to correct this by passing the recipient list down to the notification directly via the event so that the notification does not have to read the record. My problem is that I do not know how to set the email recipient in code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2011 09:48 PM
I was never able to get the "email" object to play nicely inside mail scripts. Ultimately, I wound up writing a before-insert business rule against sys_email to make the needed modifications to the recipient list. I'm doubtful this approach will help your use case b/c I believe the event params are out of scope at the Business Rule, but you might be able to identify a condition to test against and abort the first insert into sys_email. Perhaps if the event params are available you can test for equality w/ the fields in current, but it sounds like your issue occurs in the delta between the insert to sys_email and the scheduled job to process outbound messages, and I imagine the event would be long gone at that point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2011 09:46 AM
John Roberts updated the SNC wiki entry on mail scripts a couple days ago to include adding CC and BCC recipients. See: http://wiki.service-now.com/index.php?title=Scripting_for_Email_Notifications#Adding_CC_and_BCC_recipients
Still need a real API for mail scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2011 11:43 AM
As you found, not everything is accessible from the mail script, or in the right context. There's not much more that would be of much use but I'll review and get some better documentation posted at some point.