How to get styles to work on a form field, not just the list?

TrenaFritsche
Tera Expert

When I right click on a field on a form and "configure styles"...the setting of background-color:#d9e5ff; This does nothing to the form field itself....it does show and work on the list of forms.  How can I get the background of the form field to display a color?  Is there something special about it?

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

Field styles only apply in lists.  You can do this to a field on a form with a client script though.  Here is the syntax you would need in your function...

var myField = 'state';
var ctrl = g_form.getControl(myField);
ctrl.style.fontWeight = 'bold';
ctrl.style.backgroundColor = 'lightBlue';

If you're dealing with a reference field you'll need to do it like this...

var myField = 'assignment_group';
var ctrl = $('sys_display.' + g_form.getControl(myField).id);
ctrl.style.fontWeight = 'bold';
ctrl.style.backgroundColor = 'lightBlue';

View solution in original post

13 REPLIES 13

Mark Stanger
Giga Sage

Field styles only apply in lists.  You can do this to a field on a form with a client script though.  Here is the syntax you would need in your function...

var myField = 'state';
var ctrl = g_form.getControl(myField);
ctrl.style.fontWeight = 'bold';
ctrl.style.backgroundColor = 'lightBlue';

If you're dealing with a reference field you'll need to do it like this...

var myField = 'assignment_group';
var ctrl = $('sys_display.' + g_form.getControl(myField).id);
ctrl.style.fontWeight = 'bold';
ctrl.style.backgroundColor = 'lightBlue';

Thanks so much!  That is what I needed.

Is there documentation on all the possible things you can use after style? I.E. ctrl.style.fontSize, ctrl.style.italic etc.?

 

MStritt
Tera Guru

Hello! I am also trying to add a color to a field on my case form, when another field (True/False) on the form is TRUE. I want to fill the 'Account' (account) field with a color if the 'CPM Account' (u_cpm_account) field is True (checked). I've tried configuring a style (Configure Styles) on the Account field, but it doesn't appear to be working. Should I be creating a Client Script instead? If so, how would I configure it for my use case?

 

find_real_file.png