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

I am using Helsinki UI16


Hi Alex,



I am see the code run fine till my First Error alert message and later on it does not work.



function onLoad() {  



  setTimeout(function(){    


  //Change the color of the 'Approve' button to green  


      changeButtonColor('approve', '#00CC00');  


      //Change the color of the 'Reject' button to red  


      changeButtonColor('reject', '#CC0000');  


  }, 1000);  



}  


function changeButtonColor(buttonID, backgroundColor) {  


    try{  


      alert('Error Please check First');


     


          //Find the button(s) by ID and change the background color  


          $$('button[id=' + buttonID + ']').each(function(elmt) {  


   


    alert('Error Please check Second');


     


                elmt.style.backgroundColor = backgroundColor;


   


      alert('Error Please check Third');


   


                elmt.style.color = '#ffffff'; //make the button text white  


   


          });  


    }catch(e){}  


}  



Regards,


Farci


inside of your catch(), add alert(e) or console.log(e) and let me know the error that is thrown


Since this is a developer instance, would you be able to create a login for me and I can take a look? I send you a connection request so that we could private message


Logged in but do not have the admin rights needed to look at everything. Also, you can remove that login info from the post now