Approvals buttons like approve or reject button not showing Green or red color?

ch_naresh207
Giga Expert

Can we have the approval buttons coloured like they currently are in production?

Fuji:

find_real_file.png

Calgary:

find_real_file.png

I think the red and the different green helps see the right option. There is a tendency to click the update button by mistake when they are all dark green.

#

Please help me Fuji also we need different colors.

1 ACCEPTED SOLUTION

syedfarhan
Kilo Sage

Hi Naresh ,



Try this


You can use this script in an 'onLoad' client script on the table of your choice. This example should be used on the 'Approval' table.



function onLoad() {


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


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


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


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


}




function changeButtonColor(buttonID, backgroundColor) {


    try{


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


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


                elmt.style.backgroundColor = backgroundColor;


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


          });


    }catch(e){}


}



Ref: Change the Color of Form Buttons - ServiceNow Guru   for more details




Thanks


View solution in original post

9 REPLIES 9

syedfarhan
Kilo Sage

Hi Naresh ,



Try this


You can use this script in an 'onLoad' client script on the table of your choice. This example should be used on the 'Approval' table.



function onLoad() {


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


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


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


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


}




function changeButtonColor(buttonID, backgroundColor) {


    try{


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


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


                elmt.style.backgroundColor = backgroundColor;


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


          });


    }catch(e){}


}



Ref: Change the Color of Form Buttons - ServiceNow Guru   for more details




Thanks


ch_naresh207
Giga Expert

As of now we have the below script, it is correct? please help me.



function onLoad() {


    //Change the background color of the 'Reject' and 'Approve' buttons


    //get all of the 'button' tag elements in the document


    var refs = document.getElementsByTagName("button");


    if (refs) {


          for (var i=0; i < refs.length; i++) {


                var ref = refs[i];


                var inner = ref.innerHTML;


                //Check for the button 'Name' value from the UI Action record


                if (inner.indexOf('Reject') > -1){


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


                      ref.style.backgroundColor = "ff0000";


                }


                if (inner.indexOf('Approve') > -1){


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


                      ref.style.backgroundColor = "00CC00";


                }


          }


    }


}


    Hi naresh,



Use Syed Farhan   reference code from SNOW Guru its working for me   so you can try that one



srinivasthelu
Tera Guru

Hi Naresh,



The coloring feature to UI Actions is not Out of the Box even in Calgary.



That must be customization. You need to look for the script which is adding colors to these buttons and find out why it is not working in Fuji.



Another example of why not to use DOM Manipulation.



Thanks


Srinivas