his onLoad client script shows how to change the background color of form buttons in ServiceNow. For this example, I set up the script to change the color of the ‘Approve and ‘Reject’ buttons on the approval form to green and red respectively. The script itself is pretty straight-forward and can be used as a model for targeting other DOM elements using client-side JavaScript.

Form button color change

Because we’re dealing with form buttons (which are actually UI Actions) in this script, you’ll need to pay close attention to the of your UI Action. You’ll need to provide the button ACTION NAME in the script below.
This same idea can be applied to form header colors as well. Check out this article to find out how!

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) {
      //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