Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

Change Reference Field Background Color

Brent L_3
Kilo Contributor

I am trying to set the background color on a reference field. I am able to set the color of other fields but just not reference fields.

Here is what I using to set other fields.

I am doing this via a client script.

var cff = g_form.getControl(fieldname);

cff.style.backgroundColor = 'lightgreen';

 

Any help would be appreciated.

7 REPLIES 7

Ian Mildon
Tera Guru

There is a specific "case" highlighted on the ServiceNowGuru site concerning styling reference fields: click here

And the example they give is:

var myVar = $('sys_display.' + g_form.getControl('<field_name>').id); //Get the correct reference element
myVar.style.width = '350px'; //Set the width

You would want to edit the last line to be something like:

myVar.style.backgroundColor= 'lightgreen';

Thank you.  I will check this out.

vkachineni
Mega Sage

Would Field styles work for you instead of script?

Maybe,  I will have to see if that makes sense for this application.  Thanks.