How to change color of dot before incident with respect to SLA

pushparaj
Mega Contributor

Hi we have a requirement like in the ITIL home page we need to display a dot before incident number which is based on SLA duration
No Dot if SLA duration is   <80%

Amber (orange) dot when SLA hits 80% duration
if SLA breached or touched 100% then a red dot needs to be shown.

( see the image attached)

req.jpg

Pls describe how can i achieve this.

Thanks in advance

1 ACCEPTED SOLUTION

sraghunath
Tera Contributor

Hi,


I am able to achieve it using below code: and its working fine for me:



In Style : value :: javascript:DotColorerSLA() > 80


                            Style :: background-color:red;



Script Include :--> DotColorerSLA()



function DotColorerSLA() {


              var per = '';


              var gr = new GlideRecord('task_sla');


              gr.addQuery('task', current.sys_id);


              gr.query();


              if(gr.next())


                      {


                      per = gr.business_percentage;


                      }


              //gs.addInfoMessage("per-->"+per);


              //gs.log("per-->"+per);


              return per;


      }






PS: Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

13 REPLIES 13

Swapnil Bhakar1
Mega Guru

Hi Jayanthi,



Create Script include and then call the script include in field style.



Script include code:



var GlobalFunctions = Class.create();


GlobalFunctions.prototype = Object.extendsObject(AbstractAjaxProcessor,{


      getslaper : function() {


        var per = '';


              var gr = new GlideRecord('task_sla');


              gr.addQuery('task', current.sys_id);


              gr.query();


              if(gr.next())


                      {


                      stag = gr.percentage;


              }


              return per;


      }


});



After this script include define the field style for number field.


Follow below steps to define style:



1. Right click on Number field -> Click on Configure style->Click on New button.



Refer below screenshot to fill req. info.



find_real_file.png



2. Just change the value field for 100% and also change the background color red same as screenshot.


Use below value for 100%.



Value: javascript:GlobalFunctions().getslaper() >=100


background-color:Red



Hope it will help you.



Regards,


Swapnil



PS: Hit like, Helpful or Correct depending on the impact of the response


Hi Swapnil


I have created the script include in system definitions.


And i have also configured styles.
And i tried to see the changes in "incident-> all" page, but i saw no changes there.
is there some i missed or is the place i am viewing wrong ?


Hi Jayanthi,



I would suggest you create a new record and then check the changes.


It might not reflect the changes for old records.



Regards,


Swapnil



PS: Hit like, Helpful or Correct depending on the impact of the response


hi swapnil i have tried to do it.
but no luck.
and in the system logs i am getting a message called



org.mozilla.javascript.EcmaError: "GlobalFunctions" is not defined.


Caused by error in <refname> at line 1



==> 1: GlobalFunctions().getslaper()=100



does this mean anything i need to enable in my instance