Reference Field Background Colour

craigclarke
Mega Contributor

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!

6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

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

 

 

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?

it changes reference field label color.

 

 

Regards,

Sachin

HarshTimes
Tera Guru

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