Change Reference Field Background Color
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 08:55 AM
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.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 09:01 AM
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';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 04:56 PM
Thank you. I will check this out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 09:02 AM
Would Field styles work for you instead of script?
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 04:58 PM
Maybe, I will have to see if that makes sense for this application. Thanks.