Link Outgoing SLA Emails to Task

Published Categorized as ServiceNow Tagged , , , , ,

The SLA engine in ServiceNow efficiently manages Task records, such as Incidents and Cases, by sending timely email notifications to agents and management. This proactive communication helps prevent imminent breaches, ensuring that Service Level Agreements are consistently met.

Due to the structure of the SLA workflow, emails are always generated from the Task SLA [task_sla] table, an M2M table that links the Task record with the associated SLA record. As a result of this design, these emails do not appear in the Task record’s ‘Activity’ section, and any replies to these emails are not recorded within the Task.

How are these emails triggered?

A quick glance at the Notifications [sysevent_email_action] table reveals that most SLA notifications are primarily triggered by Events [sysevent].

So, how can we migrate the sent emails from the Task SLA record to the associated Task record, such as an Incident or Case? While many might attempt to accomplish this with a business rule on the ‘sys_email’ table, there’s a more effective solution when events are involved. This solution is often overlooked: server-side Script Actions [sysevent_script_action].

Configure Script Include

Since a script action needs to be configured for each event record, it’s best to centralise the shared logic. We can achieve this by defining a classless script include which will need to be invoked for moving the email to the relevant Task record.

Configure Script Actions

To move each sent SLA email, a script action must be associated with the event that triggered the email. Go to Script Actions [sysevent_script_action] and create records similar to the example below, which will invoke the reusable function we set up earlier.

global.moveSLAEmailToTask(current, eventName);

Each configured script action only requires a single line of code.

Verification

With all configurations correctly set, any SLA emails sent out will get associated to the corresponding Task. This can be confirmed in the logs and in the Task’s activity section. Additionally, any replies to these SLA emails (though rare) will also be linked to the Task record.

Next Steps

Script Actions are incredibly useful in asynchronous scenarios like this. I encourage you to explore their potential for various use cases. If I come across any more related use cases for Script Actions, I’ll be sure to share them here – tag: script action.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses User Verification plugin to reduce spam. See how your comment data is processed.