Change UI action button color

farci
Mega Expert

Hi,

I am struggling here to change the UI action button color to green when the button name is Approve and Red for button with name Reject.

Change the Color of Form Buttons - ServiceNow Guru

I also looked at the above link but to no avail.

You quickest response on this is appreciated.

Regards,

Narmi

1 ACCEPTED SOLUTION

You should be all set now. I went in and added a console.log statement inside of your "catch". This gave me the information that jquery was inaccessible, which in a scoped app it is not by default. (Scoped Applications and Client Scripts: A Primer )



I created a system property for you "x_69534_superduper.glide.script.block.client.globals" which enables this. (ServiceNow )



I disabled all of the alerts and the timeout that were set through testing and everything seems to work now.


View solution in original post

25 REPLIES 25

ravish2
Giga Expert

Please give us some more details. The article should help you. Please let us know where you are stuck. Screenshots and code will be helpful


ravish2
Giga Expert

In the Article they have used Jquery. you need to use the exact label name of the button no system name


ahaz86
Mega Guru

can you share what you have tried that isnt working?



Make sure you are setting the "Action Name" on your UI Action and then calling it in the client script.


Hi,



I tried all the options shared to me but it doesn't seem to work.


finally I tried the below code it works when I am using JavaScript Editor and not on Client script.



function onLoad() {


    //Type appropriate comment here, and begin script below



  alert('hi');


    var outage = document.getElementsByTagName('button');    


      for(i=0;i<outage.length;i++)    


      {    


          if(outage[i].innerHTML.indexOf('Approve') > -1)    


          {    


  // alert("Button color");


          outage[i].style.backgroundColor = "#00ff00";    


          }    


      }


}


find_real_file.png