How to get task sla data on an incident email notification

rosa8
Mega Contributor

I just received a request to add the business time left to all email notifications that go to the assigned user and assignment groups.
The emails contain the majority of the information included on the incident form. Is there a way using a mail script to pull the information from the incident/sla table?

6 REPLIES 6

EB
Kilo Contributor

You will have to write a script in the email notification to find the task_sla record that is connected to that incident and then you would be able to display any field form that task_sla records on that notification

http://wiki.service-now.com/index.php?title=Scripting_for_Email_Notifications


ShaneBrazeal
Tera Contributor

You could write a script in the notification to print any related SLA info in your email:



<mail_script>
var sla = new GlideRecord('task_sla');
sla.addQuery('task', current.sys_id);
sla.query();
while(sla.next()){
template.print(sla.time_left + "\n");
//at this point you can print out any fields from the task_sla table using the sla GlideRecord object looking at the example above
}
</mail_script>


Hope this helps!


Thanks loads, this is exactly what I was looking for. The only problem I'm having is that the days are printing out as 1970-01-02 the hours, minutes and seconds look great 23:48:50. I'm using bht Business Time Left and Planned End Time. Both look the same.


rosa8
Mega Contributor

DAH - getDisplayValue() gives me exactly what I'm looking for.