- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 12:41 PM
Hi SN Friends
i'm doing some things wrong but i have tired it all 😄
I have a custom UI Action button "Client button"
I want to give it a new color but nothing happens.
Script is add to the UI Action. i did also try to create a new client script where i added the script, same result.
function onLoad(){
buttonColors('erp', 'red', 'white');
// buttonColors('302fed07db8a73008e1e2dcb0b9619f4', 'red', 'white'); did also try with sysID
}
function buttonColors(buttonId, backgroundColor, color){
try{
$j("[id=" + buttonId + "]").css("background-color", backgroundColor).css("color", color);
} catch(e) {console.log(e);}
}
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 01:18 PM
This works for me. and also make sure Your Isolate script is unchecked. If you dont find it configure form layout and add it to the form.
function onLoad() {
changeButtonColor('resolve_incident', '#338AFF'); // use Action Name value from the UI Action
}
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){}
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 12:54 PM
Did you check this?
https://www.servicenowguru.com/scripting/client-scripts-scripting/change-form-button-color/
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 01:02 PM
It was my first try 😞
Can there be some sort of system property i need to change?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 01:18 PM
This works for me. and also make sure Your Isolate script is unchecked. If you dont find it configure form layout and add it to the form.
function onLoad() {
changeButtonColor('resolve_incident', '#338AFF'); // use Action Name value from the UI Action
}
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){}
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 01:23 PM
Thanks, so simple 😄 Isolate script was checked.