What is the display order when the orderBy field is empty

dorianmorel
Tera Contributor

Hello there,

 

I have a reference field Cause of Outage which lists some records based on a dependent value (CI).

 

The Cause of Outage table has an Order field, which I use to display records in my reference field. There is a record "Other" for each CI, with an Order of 10000 so they appear at the end when I want to select a value in my field.

The other records in this table have no Order for now, since it's new.

 

So my question is, what is the display order if the Order field is empty and is there a way to modify it ? 

Lets say there are 6 records listed, the record "Other" being at the end because of its 10000 order, but I can't tell how the other 5 are ordered.

 

Thank you in advance.

Dorian

3 REPLIES 3

Naveen20
ServiceNow Employee

 

When the Order field is empty (null) for some records, ServiceNow treats null as the lowest possible value, meaning those records appear before any record that has an explicit Order value. Among the records that all have a null Order, the secondary sort is typically by the display value (the field designated as the display field on the table) in alphabetical/ascending order.

So for your scenario with 6 records, the effective sort is:

  1. Records 1–5 (null Order) → sorted alphabetically by their display value (likely the Name or Label field)
  2. "Other" (Order = 10000) → appears last

To control the order explicitly, you have a few options:

Set Order values on all records — This is the simplest and most reliable approach. Assign Order values like 100, 200, 300, etc. (with gaps so you can insert new ones later), and give "Other" a high value like 10000 as you already do.

Use a Reference Qualifier with ORDER BY — If you're already using a reference qualifier on the field, you can append an ^ORDERBY clause to it. For example, if your current qualifier is something like ci=javascript:current.ci, you could make it ci=javascript:current.ci^ORDERBYname to explicitly sort alphabetically by name, or ^ORDERBYorder^ORDERBYname to sort by Order first, then by name as a tiebreaker.

Default Order on the table dictionary — You can also set a default order on the table's dictionary entry itself, which affects how records are returned globally when no explicit order is specified.

The most maintainable approach is usually the first one — just populate the Order field on all records. With gaps of 100 between values, future inserts are easy and you always know exactly what order users will see.

Tanushree Maiti
Kilo Patron

You can explicitly define the sort order for the reference field by adding an attribute to the dictionary entry of the field that references the table.

  • Right-click the field label, select Configure Dictionary.
  • Add ref_ac_order_by=field_name to the Attributes field

 

 To keep "Other" at the end, populate the Order field for the other  records with values lower than order of "Other" 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Kamva
Giga Guru
By default, reference fields are ordered alphabetically by the display value. 
 

In your case the “Other” record appears last because it has an explicit Order = 10000 and you are ordering by that field. The other 5 records (with empty Order) are not ordered by Order • They are simply ordered alphabetically by the display value.

This is why the order looks “random” if the names don’t follow a clear alphabetical pattern.