Unable to get DOT beside Incident Number field depend on the SLA Calculation

shaik25
Tera Contributor

Hi all,

 

I have a requirement on Incident list view, When ever the Resolution SLA got breached the red color DOT needs to appear beside the number field from list view. I have tried below  steps but not working as expected.

 

1 Script include.

 

function DotColorerSLA() {
 
 
    var per = '';
    var gr = new GlideRecord('task_sla');
    gr.addQuery('task', current.sys_id);
gr.addEncodedQuery('target=resolution');
    gr.query();
   // gs.addInfoMessage("this is after query");
    if (gr.next())
 
    {
        gs.addInfoMessage("this is  after next");
        per = gr.business_percentage;
 
 
      //  gs.addInfoMessage("per-->" + per);
        return per;
    }
}

 

2. Configured in Number field with style module.

 

shaik25_0-1690289510672.png

 

 

 

 

2 REPLIES 2

Tushar
Kilo Sage
Kilo Sage

Hi there,

 

your code is not checking if the SLA is breached or not.

 

Try the following -

 

function DotColorerSLA() {
    var gr = new GlideRecord('task_sla');
    gr.addQuery('task', current.sys_id);
    gr.addEncodedQuery('target=resolution');
    gr.query();
    
    if (gr.next()) {
        var percentage = gr.business_percentage;
        if (percentage < 100) {
            gs.addInfoMessage("The SLA is breached!"); // You can display a message or add additional logic here.
            return 'red'; // Return 'red' to apply the red color dot.
        } else {
            return ''; // Return an empty string if the SLA is not breached.
        }
    }
}

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

shaik25
Tera Contributor

Hi Tushar,

Thank you for your quick response,

I have updated code in script include with your code, but  the number field is not showing red dot after breach of SLA.it should  visible same as below priority has.