- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-10-2017 06:29 PM
I had this buried within another post so I thought I would share it here as I see this type of question get asked a lot on the community.
My solution will not be perfect for everyone, but it should give a nice base to start from:
First I created a new field on the Incident table called SLA State (u_sla_state), I placed it on my incident record just under the CI field.
I then added a dictionary calculated value to this field, to do this, right click on the field label for SLA State and 'Configure Dictionary'
Then under related links, click advanced view. This should reveal the Calculated Value tab.
Insert this script:
(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 < 75) {
return 'SLA Met!';
}
else if (gr.business_percentage < 100) {
return 'SLA Risk!';
}
else {
return 'SLA Breach!';
}
}
})(current);
I then created a System Definition / UI Action called "SLA State" with the following checkboxes: Show insert, show update, client, list v2 compatible and list v3 compatible.
Script is:
var SLAValue = g_form.getValue('incident.u_sla_state');
var SLAStyle = g_form.getElement('incident.u_sla_state');
if (SLAValue == "SLA Met!") {
SLAStyle.style.backgroundColor = 'lightgreen';
}
else if (SLAValue == "SLA Risk!") {
SLAStyle.style.backgroundColor = 'orange';
}
else if (SLAValue == "SLA Breached!") {
SLAStyle.style.backgroundColor = 'tomato';
}
Lastly, I set up a few field styles to emphasize the colors:
This combined makes the incident list look like so:
Incident preview (List V2 only):
And finally, the incident itself:
As you can see, its very colorful and makes it very obvious what state the SLA is in. I am pretty sure this does not update in real time for List V2, but it should for List V3 however, you may need to reload the incident list / incident itself to see changes.
Hope this meets some peoples requirements.
Best regards,
Kris.
This document was generated from the following discussion: Solution - Changing field style by SLA state
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If any of the above steps are not clear, please let me know.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Is this also compatible with SCTASK table ?