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

Mark Stanger
Giga Sage

It sounds like this is working, but it's not working when you're adding the field as a derived field to the form through another reference field.  If that's the case, you just need to dot-walk an extra step through the first reference field to get the correct ID.

var myField = 'NAME_OF_FIRST_REFERENCE_FIELD_HERE.u_version_number';

craigclarke
Mega Contributor

Thanks for replies I got it working as follows (the dotwalk was incorrect and the syntax had to be changed):

g_form.getControl('sys_display.task_ci.u_version_number').style.backgroundColor = "yellow";