- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 05:30 AM
Hi,
I am struggling here to change the UI action button color to green when the button name is Approve and Red for button with name Reject.
Change the Color of Form Buttons - ServiceNow Guru
I also looked at the above link but to no avail.
You quickest response on this is appreciated.
Regards,
Narmi
Solved! Go to Solution.
- 14,605 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 06:14 AM
You should be all set now. I went in and added a console.log statement inside of your "catch". This gave me the information that jquery was inaccessible, which in a scoped app it is not by default. (Scoped Applications and Client Scripts: A Primer )
I created a system property for you "x_69534_superduper.glide.script.block.client.globals" which enables this. (ServiceNow )
I disabled all of the alerts and the timeout that were set through testing and everything seems to work now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2021 03:19 AM
where can i find the Button ID?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 01:11 AM
Hi,
This code seems to work when I am using JavaScript Editor but not when I am using On Load, Client Script unable to figure out what is the hindrance.
see the screenshot and code below
//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){}
}
You earliest response is much appreciated.
Regards,
Narmi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 04:50 AM
Try this, I added a 1 second delay in executing the code
function onLoad() {
setTimeout(function(){
//Change the color of the 'Approve' button to green
changeButtonColor('approve', '#00CC00');
//Change the color of the 'Reject' button to red
changeButtonColor('reject', '#CC0000');
}, 1000);
}
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){}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 05:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 05:16 AM
can you check the error console? try adding an alert right under the onload function on line 2 to see if your client script is even firing