The CreatorCon Call for Content is officially open! Get started here.

Pulling SLA Due Dates for Email Notifications

Ben28
Tera Contributor

Hi,

I'm creating some email notifications for Problem tickets, so Problem owners will get an email notification when assigned, and give them the SLA due date. Also another for when the SLA hots 50%, 75% and 100%.

In the 'Problem Assigned to' notification, I'm having some trouble pulling the SLA, when the Problem SLA has changed, such as a P1 Problem (30 day SLA), change to a P2 Problem (40 day SLA). The email, which is using the Problem [problem] table, is showing both SLA's rather than just the current SLA, (see below pic). How can I pull just the current/most recent SLA for each Problem?

Ben28_0-1690414040621.png

My mail_script is:

 

 

{
var sla = new GlideRecord('task_sla');
sla.addQuery('task', current.sys_id);
sla.query();
while(sla.next()){
	template.print(sla.planned_end_time + "<br>");
}

 

 

In the SLA notification email, I'm pulling from the Task SLA [task_sla] table, and trying to show the SLA due date, as well as the business time left, the latter shows fine. I've tried both ${task.due_date}, ${task.sla_due}, as well as just ${due_date}, ${sla_due}, but only shows 'UNKNOWN' or blank, not the actual date. How can I pull the SLA due date?
Ben28_1-1690414402537.png
Any advice or pointers greatly appreciated!
1 REPLY 1

Hema P
Tera Guru

Hi @Ben28 

"template.print" does not work inside the loop so, we need to store the value in variable. Please try below code.

{
var sla = new GlideRecord('task_sla');
sla.addQuery('task', current.sys_id);
sla.query();
while(sla.next()){
var getDueDate = sla.planned_end_time;
}
template.print(getDueDate+ "<br>");