Jim Coyne
Kilo Patron

I talked about performing a sanity check on Inbound Email Actions in my last blog entry - Inbound Email Actions Sanity Check.

The Inbound Email Action would fire an event if there were more than 20 lines in the email message. An Email Notification was setup to listen for that event and would notify the administrators of the problem email. I wanted to include a link to that problem email so the admins could just click on the link to go directly to it instead of forcing them to look for it. After a lot of digging around, I finally found a way to do it properly.

The Inbound Email Action fires an event with the following line of code:

gs.eventQueue("sys_email.u.mail_integration.max.records.exceeded", sys_email, null, null);

The trick is the "sys_email" variable - it is actually a record of the email the Inbound Email Action is working on. It is not currently documented in the Inbound Email Action wiki article, but I found it buried in some release notes for the Spring 2009 release - http://wiki.servicenow.com/index.php?title=Spring_2009_Notable_Changes#New_.22sys_email.22_global_variable_available_to_Inbound_Email_Actions.

So by including it in the eventQueue call and configuring the notification on the "Email [sys_email]" table, the event is tied to the email record and we can access the record with "current" in some mail_script within the message of the notification:

An email has been received which exceeds the number of expected records.

<mail_script>
   var url = gs.getProperty("glide.servlet.uri") + "nav_to.do?uri=sys_email.do?sys_id=" + current.getValue("sys_id") + "%26sysparm_view=inbox";
   template.print("<a href='" + url + "'>Click this link to view the email.</a>");
</mail_script>

 

And the result is the following:


find_real_file.png

1 Comment