Incident SLA Due > UNKNOWN value

marc_lambert
Kilo Explorer

Hi to everyone

We are running SNC version January 2012 and we do have an unexpected result regarding the "SLA Due" field which contain "Unknown" where we believe, the value should be populated with the Resolution Date/Time Expected whichi is defined within our SLA.

The SLA is running properly and all our Business Rules related to "sla" are also activated.

Thank's for your help

11 REPLIES 11

CapaJC
ServiceNow Employee
ServiceNow Employee

I don't think that field is used anymore, since a task can now have multiple SLAs against it, and a single date/time field no longer has meaning. The relevant information would instead be found in one or more Task SLA records in a related list on the Incident form.


Thank's for your input


bburdick
Mega Guru

Even though the sla_due field is legacy, we still wanted to have a single field that let our techs to sort their incidents in a list by the earliest due date. So we created a custom business rule that populates that field.

Here is the code if you are interested:

Name: Set SLA Due
Table: Incident
When: After
Update: True



var gr = new GlideRecord("task_sla");
gr.addQuery("task", current.sys_id);
gr.orderBy("planned_end_time");
gr.query();
if (gr.next()) {
gs.addInfoMessage("Planned end " + gr.planned_end_time);
current.sla_due = gr.planned_end_time;
current.update()
}


This will remove the UNKNOWN issue you are seeing.


sdarity1
Tera Contributor

The previously proposed business rule has a flaw where a Double Update will occur on the Incident Record when current.update() is called in the After "Update" Business Rule.

The following new business rule will update the sla_due field on the incident when the associated task_sla is inserted or updated.

Name: Set Incident SLA Due
Table: task_sla
When: After
Insert: True
Update: True

Condition: current.sla.collection == 'incident' && current.stage.changes()

Script:
var new_sla_due;
var gr = new GlideRecord("task_sla");
gr.addQuery("task", current.task);
gr.addQuery("stage", '!=', 'achieved');
gr.orderBy("planned_end_time");
gr.query();
if (gr.next())
{
new_sla_due = gr.planned_end_time;
}

if (new_sla_due)
{
var incidentRec = new GlideRecord('incident');
incidentRec.addQuery('sys_id', current.task);
incidentRec.query();
if(incidentRec.next())
{
incidentRec.sla_due = new_sla_due;
incidentRec.update();
}
}