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

Hi Jayanthi,



Replace GlobalFunctions with your script include name or you can give same name for your script include as GlobalFunctions.



Hope it will help you.



Regards,


Swapnil



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




Hi Swapnil.


i have named my script include as "DotColorerSLA"
and API name is "global.DotColorerSLA"



And i have used the code as you have provided


""


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())


                      {


                      per = gr.percentage;


              }


              return per;


      }


});


            ""


And i have tried the value field by replacing GlobalFunctions with scriptinculde name as



javascript:new global.DotColorerSLA().getslaper()=100


javascript:global.DotColorerSLA().getslaper()=100


javascript:DotColorerSLA().getslaper()=100


javascript:new DotColorerSLA().getslaper()=100


but still out of luck


Hi Jayanthi,



Use below modified code and just copy & paste it in your script include:




var DotColorerSLA = Class.create();


DotColorerSLA.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())


                      {


                      per = 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.



For 80% define below value and style for Number field



Value: javascript:DotColorerSLA().getslaper() >=80


Style: background-color:Orange



For 100% define below value and style for Number field



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 done the script include and filled the value field as per what you sent.


I have also done the styles as you said. still no luck.


i am attaching the screen shots of my current doing for reference.




1.JPG2.JPG


You should use '==' instead of '=' in your condition.