Solution: presenting color-coded elapsed SLA resolution time in the incident lists

mitzaka
Mega Guru

Hey SNC,

I know there are a bunch of open articles about the topic in the community, so I decided to put up an article with my solution of this.

The case was: we needed to present the Resolution SLA elapsed percentage (time between start and end, minus the paused time) in the Incident list views, and color code the incidents based on the elapsed time. (NOTE: in the case where we have more than just one SLA task attached to a record, because I know the use-case of just one can be done simpler)

So, here goes:

1. new read-only field on the incident table called 'Resolution SLA %', does not need to be on the form

2. new before business rule on the task_sla table with the condition of: 'actual elapsed percentage changes' && 'SLA contains resolution'; the script looks up the related incident and updates the 'Resolution SLA %' field as per the change in the 'Actual Elapsed Percentage' field:

function onBefore(current, previous) {

if (current.task.sys_class_name == 'incident') {

      var gr = new GlideRecord('incident');

      if (gr.get(current.task.sys_id)) {

  gr.u_resolution_sla = current.percentage;

              gr.update();

}

}

}

3. new field background-color styles on the 'Number' field in Incident form, which colors the incidents which are within a specified percentage range and in the states you want (I wanted only the ones In Progress and Open to be colored). The value of the field style goes like this (1 and 2 are the states which I want to color)

javascript: (current.u_resolution_sla >= 75 && current.u_resolution_sla < 100) && (current.state == '1' || current.state == '2');

4.new field color styles on the 'Resolution SLA %' field in Incident form, which colors the percentage displayed when in the specified range of percentage. Value looks like that:

javascript:current.u_resolution_sla >= 1 && current.u_resolution.sla < 75;

5. SLA actual elapsed time is by default calculated by a scheduled job and will run at 50%, 75% and 100%. However, if you want the actual elapsed percentage to be updated on every task_sla form load, then you can turn on a system property called 'glide.sla.calculate_on_display'; It could cause performance issues as it loads on the client side, but only in the cases where you have multiple SLAs attached, and you can always turn it back off if so. Or you could change the default workflow 'Standard SLA' and set up more trigger points than just 50/75/100. More useful info on this here: Configuring SLA Calculations with the glide.sla.calculate_on_display property

So here is how the outcome looks like - it applies the traffic lights to your incident list view based on the elapsed resolution SLA percentage. Beautiful:)

find_real_file.png

23 REPLIES 23

cfam1
Mega Expert

Thanks so much for this post! It works great and was just what I needed


Glad it works for you Chandra!:)


Hey Dimitar,



I have implemented this successfully before with no issues but now our instance is on Istanbul Patch 6 and I can't seem to get this to function properly.   It won't populate the field when the ticket is submitted.   It does seem to run if you open an existing ticket and change the priority but then it may not use the correct SLA then (since when you change the priority, the Resolve SLA will change).   Do you have any ideas as to what could be wrong in the new version?   I still have this successfully running in my PDI which is on Helsinki version so this is baffling to me.dimitardimitrov



Thanks,


Chandra


palmen
Tera Guru

Thanks for this post, it'll help us!


Onl ything I don't get to work is the color coding, but that might be something in our instance.


I'm using a field style like this but it's not applied in the list


find_real_file.png