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

Tushar Atakari
Tera Contributor

Hi,

 

Field styles only apply in lists like at the priority tab in list view.

 

You can style form fields using client script though. for further query refer to servicenow docs.

 

mark helpful if you find it useful.

Thanks 

Ankush Jangle.

Ankush Jangle1
Kilo Guru

Hi,

 

Field styles only apply on lists.

 

You can edit fields on a form with a client script.

 

Mark Helpful

 

Thanks,

Ankush Jangle.

Tarique Wasim1
Giga Contributor

If I right on fields on form and go to Configure Style and apply the style for that particular field then it is applying on the form field only.

Rupali8
ServiceNow Employee
ServiceNow Employee

Create 2 entries in the UI style table, one with Value field with the value and one with Value field empty. This will allow styling on both form and list.