sable
Mega Contributor

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'

find_real_file.png

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:

find_real_file.png

This combined makes the incident list look like so:

find_real_file.png

Incident preview (List V2 only):

find_real_file.png

find_real_file.png

find_real_file.png

And finally, the incident itself:

find_real_file.png

find_real_file.png

find_real_file.png

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

Comments
sable
Mega Contributor

If any of the above steps are not clear, please let me know.


Bird Petcharayu
Kilo Contributor

Is this also compatible with SCTASK table ?

Version history
Last update:
‎10-10-2017 06:29 PM
Updated by: