How to apply green color to approve button and Red color to reject button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:11 AM
Hi Team,
How to apply green color to approve button and Red color to the reject button.
Please provide the solution.
Regards,
Mahesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:19 AM
Hi @maheshch18 ,
Hope you are doing great.
To apply green color to the "Approve" button and red color to the "Reject" button in ServiceNow:
Identify the unique HTML element IDs or classes of the "Approve" and "Reject" buttons on the form.
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();
}
}
}
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:02 AM
Hello @maheshch18 ,
Please refer to this: https://www.linkedin.com/pulse/3-ways-color-ui-actions-servicenow-rene-el-hamzh
Thanks!