How to apply green color to approve button and Red color to reject button

maheshch18
Tera Contributor

Hi Team,

 

How to apply green color to approve button and Red color to the reject button.

 

Please provide the solution.

 

Regards,

Mahesh.

2 REPLIES 2

Riya Verma
Kilo Sage
Kilo Sage

Hi @maheshch18 ,

 

Hope you are doing great.

 

To apply green color to the "Approve" button and red color to the "Reject" button in ServiceNow:

  1. Identify the unique HTML element IDs or classes of the "Approve" and "Reject" buttons on the form.

  2. using client-side scripting (JavaScript or Jelly), target these elements and apply the desired styles.

sample script to apply css changes in button:

 

function applyButtonStyles() {
    // Replace 'approveButton' and 'rejectButton' with the actual IDs or classes of your buttons
    var approveButton = document.getElementById('approveButton');
    var rejectButton = document.getElementById('rejectButton');

    if (approveButton && rejectButton) {
        // Apply green color to the "Approve" button
        approveButton.style.backgroundColor = 'green';
        approveButton.style.color = 'white';

        // Apply red color to the "Reject" button
        rejectButton.style.backgroundColor = 'red';
        rejectButton.style.color = 'white';
    }
}

// Call the function once the form has loaded
addLoadEvent(applyButtonStyles);

// Utility function to handle form load event
function addLoadEvent(func) {
    var oldOnload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function () {
            if (oldOnload) {
                oldOnload();
            }
            func();
        }
    }
}

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Community Alums
Not applicable