Change color of a UI Action

Daniel Christen
Kilo Contributor

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);}
}

 

1 ACCEPTED SOLUTION

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.

find_real_file.png

 

find_real_file.png

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

View solution in original post

4 REPLIES 4

Prateek kumar
Mega Sage

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

Daniel Christen
Kilo Contributor

It was my first try 😞

Can there be some sort of system property i need to change?

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.

find_real_file.png

 

find_real_file.png

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

Daniel Christen
Kilo Contributor

Thanks, so simple 😄 Isolate script was checked.