How to change font color in field but not list view?

Mat Gdowski1
Tera Contributor

Hey all,

I'm hoping for some help.  We are currently using a Field Style to change the Number field on Incident to a blue background with a white font.

With that being said, if, in List View, you move the column for the Number field to a column other than the first column, the white font disappears on the white background.

Is there any way to keep the font and background color changes for the field itself on the form, but make the font black in List View only?

Thanks!
Mat G.

find_real_file.png

5 REPLIES 5

AnirudhKumar
Mega Sage
Mega Sage

To make the UI Style apply only to form, I suggest go with Onload client script.

var numberField = $('incident.number');
numberField.setStyle({color: "white",backgroundColor: "skyblue"});

Thank you.  I will try that out.

Ankur Bawiskar
Tera Patron
Tera Patron

@Mat Gdowski 

for form you need to use script combination of Display BR + onLoad client Script

DOM manipulation is not required.

1) Display business rule on incident table

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	g_scratchpad.updatedBy = current.sys_updated_by;
	g_scratchpad.assignedToUser = current.assigned_to.user_name;

})(current, previous);

2) on Load client script

function onLoad(){
	var control = g_form.getControl('number');
	if(g_scratchpad.updatedBy == g_scratchpad.assignedToUser){
		control.style.color = 'white'; // to set the color of field
		control.style.backgroundColor = "blue";   // to set the background color
	}
	else{
		control.style.color = ''; // to clear the color of field
		control.style.backgroundColor = "";  // to clear the background color
	}
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Mat Gdowski1
Tera Contributor

Ankur,

 

Thank you for the information.  I did try both scripts and removed the Field Styles script and I could not get it to work.  I'm not sure why or if I am missing something.