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

Field style works only on list view, not on form view.

SOLUTION - Instead of writing a client script, make the target field "Read only", Field style will work then and field should have some data contained in it. E.g. Incident number field which is coming automatically on form load, etc.

It works. 

 

Regards,

Shubham

Unfortunately, I can't make the target field (Account) read only. There's no other way to fill the field with a color?

 

Mike

Did you try an OnChange client script for CPM Account...when the value is true, try writing something like Mark Stranger identified for a reference field:

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

Change the myField to be the field name for Account and see if something like that works when you click the box of CPM Account.  I remember that I was able to get this to work where I needed to.  

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

When I attempt to create a Client Script (onChange) on the Case form/table, I don't see the CPM Account field. The CPM Account field is actually on the Account table. The CPM Account and Assigned CPM fields were created on the Account form/table. Then, I created a UI Policy on the Case table to show these 2 fields on the Case form if CPM Account was TRUE. These 2 fields were added to the Case form via Configure Layout (Account.CPM Account & Account.Assigned CPM). 

find_real_file.png

find_real_file.png

Hi Trena,

I got the field color to work using the code you mention. How can I configure the code to use an icon instead of a background color? How would I change:

ctrl.style.backgroundColor = 'lightBlue';

to use an icon?

images/icons/flag_red.gif