color incident field based on SLA/Aging
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2017 06:24 AM
Hi All,
We have a SLA running on our Servicenow, but there is no color coding in the incident field( color coding is on Priority field ).
Can we color Incident field based on SLA and the aging ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2017 11:16 AM
You will need three different field styles defined - one for each value and color.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2017 05:09 PM
Hi again Bijender,
If my responses have helped, can you please mark them as helpful?
I am a little confused as to your request so to clarify:
< 50 = green
> 50 & < 75 = something?
> 75 & < 100 = orange
> 100 = red
Either way, you just write the calculated dictionary value like so:
(function calculatedFieldValue(current) {
var gr = new GlideRecord("task_sla");
gr.addQuery('task', current.sys_id;
gr.setLimit(1);
gr.query();
if (gr.next()) {
if (gr.business_percentage < 50) {
return 'SLA Met!';
}
else if (gr.business_percentage < 75) {
return 'Getting warmer!';
}
else if (gr.business_percentage < 100) {
return 'SLA Risk!';
}
else {
return 'SLA Breach!';
}
}
})(current);
Then you just need to set up the UI Action and Field Styles to match whatever you put into the script (SLA Met!, Getting warmer! etc)...
- Kris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 03:32 AM
Hi Kris,
the script that worked is "checkSLA"and the other Globalfunctions is not working on my SNOW environment, may be i am doing something wrong.
i thought the script " checkSLA" if we can add the condition like if SLA percentage is <75 incident field color is green, if between 75&&100 color is orange and if 100 color red
I am not as good as you in scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 05:25 PM
Hi Bijender,
My apologies, I just noticed an error in the previous script I posted...
(function calculatedFieldValue(current) {
var gr = new GlideRecord("task_sla");
gr.addQuery('task', current.sys_id); // <-- missed a closed bracket here!
gr.setLimit(1);
gr.query();
if (gr.next()) {
if (gr.business_percentage < 50) {
return 'SLA Met!';
}
else if (gr.business_percentage < 75) {
return 'Getting warmer!';
}
else if (gr.business_percentage < 100) {
return 'SLA Risk!';
}
else {
return 'SLA Breach!';
}
}
})(current);
My original script (now located at Solution - Changing field style by SLA state describes how to implement this with SLA percent of < 75, < 100 and > 100 as you described. So long as you follow those instructions (and I have gone into quite a lot of detail) you should be able to get this working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 05:37 AM
Hi Kris,
Thanks , i checked this, but to make it work we need to create a new field "SLA State " can we do without it and color the incident number field ?
As in like "CheckSLA "script is coloring the number field when ticket is breached, so if possible can we do the same :
- if SLA percentage is <50 : background color: green
- if SLA percentage is >50 && <100 : background color: orange
- if SLA percentage is >=100 : background color: red(which is done by Check SLA script )