ServiceNow field styles are CSS rules attached to individual fields. They can change a field’s text color, font emphasis, padding or alignment in a list or on a form. You create one from a form or System UI, choose the table and field, enter the Value that triggers it, and add the CSS. Form layout controls placement separately.
Creating a field style from a form or System UI
Two routes open the same list of styles. On a form, right-click the field label and choose Configure, then Styles. Administrators can also go to System UI, then Field Styles, and locate the field there. Creating or changing a style needs the personalize_styles role or the admin role. For the wider picture of access on this platform, see the instance security and access control hub.
From the list, select New to create a style, or open an existing one. The form has four entries: the Table that contains the field, the Field name the style applies to, the Value that triggers it, and the Style, which is the CSS. Select Submit to save a new style or Update to save a change to one.
The Table list is filtered by scope. It shows tables and database views that meet the scope protections for field styles. A style can target tables and database views in its own scope, and it can also target another table that has at least one field in that scope. If a table you expect is missing from the list, the scope of the style is the first thing to look at.
Writing the Value and the CSS
The Value decides which interface receives the style. Leave it empty to apply the style to forms in the UI16 interface. Enter a value to apply it to lists in the UI16 interface. The Value can be an exact value the field has to hold, or a script-based condition.
The CSS can change a field’s text color, its bold, italic and underline attributes, the padding around its text, and the alignment of that text. A worked example makes the background of Incident Category fields red in record lists, with a 24-pixel font size and white text. That takes three declarations: a background color, a font size and a text color.
A condition that depends on the record starts with javascript: followed by the script. When the script returns true, the style applies to that list item. The script can read the current record through the current script object, so a condition can compare fields on the same record. A common use is flagging overdue items. For a custom date field named u_datefield, the condition gs.dateDiff(gs.now(), current.u_datefield.getDisplayValue(), true) < 0 flags items whose date has passed. Replace u_datefield with the real column name on your table.
A Value field accepts one javascript: entry. Two separate entries in the same field are not valid. Join the conditions into one statement with &&, for example javascript: current.state == “Completed” && current.error_tables > 0.
Alternative text for styled fields
Some styles carry a meaning that the field text does not. The VIP style icon is an example. To give those styles a text equivalent, configure the form to add the alternative text field. Write a short description of what the style means, rather than repeating the field value. A screen reader can then tell the style apart from the text.
Placing fields with Form Layout
Form layout is a separate task from styling. A user with the personalize_form role, or an administrator, opens the form context menu, chooses Configure, and then selects Form Layout. Fields move from the Available list to the Selected list, and moving them up or down sets their order there. Items shown in green with a plus sign are related tables. To reach their fields, use dot-walking.
Do not add the same editable field to two sections. Two editable copies can cause data loss and stop UI policies and data policies from working as intended. A second copy is acceptable when it displays read-only data.
Related lists are added through Configure, then Related Lists, and they appear at the bottom of the form. Lists can also be embedded inside a form. Changes made in an embedded list are saved when the form is saved. Users can create records in the list view, subject to the roles you set for the embedded list. In Core UI, the order of the Additional Comments and Work Notes fields is set through activity customization rather than through Form Layout.
A chart can be added to a form, but the List, Pivot, Multilevel Pivot, Calendar and Single Score report types are not supported on forms.
Sections, splits and tabs on a form
Creating a section needs the form_admin role. Select New in the section list, enter a caption, and select OK. The caption of the first section becomes the form title, so it deserves careful wording. Arrows change section order. To delete a section, go to System UI, then Form Sections, filter for the table, select the row, choose Delete from the actions menu, and confirm.
Split indicators, named begin_split, split and end_split, mark where the fields on a form split. They sit in the Selected list and move with the up and down arrows. The role required for this is admin.
Tabbed forms give each form section and each related list its own tab, and the first section is the one users see first. Tabs are on by default for new instances, controlled by the tabbed.forms system user preference. An individual user can switch them off under User Menu, then Preferences, then Display.
Annotations that explain a form
Annotations place instructions or highlighted text on a form. Select a section under Form view and section, move the * Annotation item into the Selected list, and place it above the field it explains. The available types are Info Box Blue, Info Box Red, Line Separator, Section Details, Section Separator and Text. The data type is Plain Text or HTML. With HTML, valid tags render, so an annotation can carry inline red text.
Each user can show or hide annotations through the glide.ui.show_annotations user preference. Annotations are enabled by default, and an administrator who wants them off sets the glide.ui.form_annotations system property to false. For translations, create a message record for each language under System UI, then Messages, and use the annotation text as the shared key. Reference the message inside the annotation with gs.getMessage, in the form ${gs.getMessage(“key”)}. Annotation types live under System UI, then Form Annotation Types, where setting Active to false stops a type from being used.
Form Builder and form designer
Form designer is a drag-and-drop tool. It is on by default for new instances and requires Core UI. An instance that was upgraded must activate the Form Designer plugin, com.glide.ui.ng.fd. To open it, select the Additional actions icon on an existing form, then Configure, then Form Design. Each form is tied to one table and view pair, so the incident default view has its own form, and a different view has its own layout.
Sections in form designer use a one-column or two-column layout. The first section is read-only, displays the table label, and cannot be removed. Starting with the Australia release, form designer is being prepared for future deprecation. Form Builder includes the form designer options and the Form Layout options, plus further configuration tools, so new configuration work is better started there.
Adding a field before you style it
A field has to exist before it can be styled. From a form, choose Configure, then Form Layout. In the Create new field section, enter a Name, select a Type, select a Field length where the type offers one, click Add, place the field with the slushbucket, and save. Custom column names receive a u_ prefix, and any leading numbers in the label are replaced by it.
Database limits apply when fields are added. A table can hold up to 1,000 columns, though the database in the datacenter decides how many a table can physically carry. Each table has a row size limit of 65,535 bytes, and storage engines can reduce it further. A table cannot have more than 10 medium-length or longer String fields. Eleven or more String fields holding a large amount of text can fail with a row-size error.
Where field styles do not reach
Field styles are not supported in Workspaces, so a style built for a classic form or list will not appear there. The UI Builder and Workspaces guide covers the newer interface. A style defined for a table does not carry over to a database view that includes that table, so a separate style is needed for each view. Comments and work notes in the activity formatter are not styled either. Their background color is set through the glide.ui.activity_stream.style.comments and glide.ui.activity_stream.style.work_notes system properties, which live in the sys_properties table.
Frequently asked questions
Can one field style apply to forms and lists?
Not with one style. An empty Value applies the style to forms in the UI16 interface, and a specified value applies it to lists in the UI16 interface, so a single Value cannot cover both.
How do I style a field once a date has passed?
Write the Value as a javascript: condition that uses gs.dateDiff with gs.now() and your date field, and test for a result below zero. Items that match are flagged in the list.
Why does my style not show on a database view?
A style defined for a table does not apply to a database view that includes that table. Create a separate style for the view.
Can a field style color comments and work notes?
Not directly. The background color of those fields is set through the glide.ui.activity_stream.style.comments and glide.ui.activity_stream.style.work_notes system properties.
Do field styles work in Workspaces?
No. Field styles are not supported in Workspaces.