Solution: presenting color-coded elapsed SLA resolution time in the incident lists
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2015 07:37 AM
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:)
- 12,182 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2016 02:13 AM
palmen - which list are you looking in? This would only work in Incident lists, it will not apply for example if you look in the 'My Work' list which is based off the 'task' table.
Also, I think in the style field, you should use : 'background-color:green', instead of 'color:green'.
Let me know if that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2016 02:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2019 06:38 AM
Yeah , i tried the same but it is not working
then try this code it will work
javascript: (current.u_resolution_sla>1&¤t.u_resolution_sla<75)|| (current.u_resolution_sla==1);
this code is complex but it is working for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 04:36 AM
Style should be background-color:green;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2016 02:36 AM
Great article Dimitar, surely an easier way to find out the latest status.