Reference Field Background Colour
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 02:27 PM
Hi
I am hoping someone may be able to help with an issue I am having. I am attempting to conditionally change the background colour of reference fields in forms and in lists. I have succeeded on the base form and list using Client Script and Style. Where I have included the field in question on other forms for information I am not able to affect the style.
I have attempted to force a visual change using the following code in a client script, but there was no change:
function onLoad() {
//Type appropriate comment here, and begin script below
var myField = 'u_version_number';
var ctrl = $('sys_display.' + g_form.getControl(myField).id);
ctrl.style.backgroundColor = 'yellow';
}
Our version is London. Any help would be appreciated, I guess I am missing something very basic!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 03:01 PM
Use below to change
function changeFieldLabel(field, label, color, weight,bgColor){
try{
var labelElement = $('label.' + g_form.getControl(field).id);
labelElement.select('label').each(function(elmt) {
elmt.innerHTML = label + ':';
});
if(color)
{
//Label Color
labelElement.style.color = color;
//Label Background color
labelElement.style.background = bgColor;
}
if(weight)
labelElement.style.fontWeight = weight;
}catch(e){}
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 03:26 PM
Thank you Sachin for the speedy reply. Does this example code change the reference fields label (prompt) or is it actually changing the field properties?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 03:40 PM
it changes reference field label color.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 04:19 PM
Hi
You can try below simplified code, this will help.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var fldName = "Name_of_your_filed" ;
var lblElementId = g_form.getLabel(fldName);
lblElementId.style.backgroundColor = "red";
}