- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 08:11 AM
ServiceNow Version: London
I have added an approve and reject UI action button in the change_request form which work fine. However i would like to change the color of these buttons to green and red respectively. I have added the client script to try and do this based on my research. Can anyone tell me what I am missing or if its more involved than just those 2 things?
UI Action for approve:
Client Script for color change:
Solved! Go to Solution.
- Labels:
-
Best Practices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2019 07:34 AM
Hi,
If I'm understanding you correctly in that you just want to change the color of your UI Action button on the form...no client script in necessary. There's a field called "Form style" as seen in your screenshot and contains a few styles already OOB. One is "Destructive" which is red...so set your reject button to that style and that one is done.
For the Green version...you'd have to create that...please see this thread and specifically look for Chuck's response that gives details on how to add other colors: https://community.servicenow.com/community?id=community_question&sys_id=d2494725db5cdbc01dcaf3231f96...
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 08:27 AM
Hii
They way i have done it in past is:
On Line 3==> changeButtonColor('<action name of button>', '<class Name>'); //class name can be success/danger etc.
Function on Line 8:
function changeButtonColor(buttonID, style) {
try{
$$('button[id=' + buttonID + ']').each(function(elmt) {
var jelmt = $j(elmt);
jelmt.removeClass('btn-default');
jelmt.addClass('btn-'+style);
});
}catch(e){}
}
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2019 07:27 AM
I got this now:
function onLoad() {
//Change the color of the 'Approve' button to green
changeButtonColor('Approve', 'success');
//Change the color of the 'Reject' button to red
changeButtonColor('reject', '#FF0022');
}
function changeButtonColor(buttonID, style) {
try{
$$('button[id=' + buttonID + ']').each(function(elmt) {
var jelmt = $j(elmt);
jelmt.removeClass('btn-default');
jelmt.addClass('btn-'+style);
});
}catch(e){}
}
Still doesn't change color. Could there be something blocking it from changing color?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2019 07:38 AM
Try this
function onLoad() {
//Change the color of the 'Approve' button to green
changeButtonColor('approve', 'success');
//Change the color of the 'Reject' button to red
changeButtonColor('reject', 'danger');
}
function changeButtonColor(buttonID, style) {
try{
$$('button[id=' + buttonID + ']').each(function(elmt) {
var jelmt = $j(elmt);
jelmt.removeClass('btn-default');
jelmt.addClass('btn-'+style);
});
}catch(e){}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2019 07:34 AM
Hi,
If I'm understanding you correctly in that you just want to change the color of your UI Action button on the form...no client script in necessary. There's a field called "Form style" as seen in your screenshot and contains a few styles already OOB. One is "Destructive" which is red...so set your reject button to that style and that one is done.
For the Green version...you'd have to create that...please see this thread and specifically look for Chuck's response that gives details on how to add other colors: https://community.servicenow.com/community?id=community_question&sys_id=d2494725db5cdbc01dcaf3231f96...
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!