How to show customized ordered records in List view

Avee90
Tera Contributor

Hi everyone,

I have a custom table with the following fields: Category(Choice field with options: Application, General, Network, Software, Password), Order(String), and Inactive(Checkbox).

I'm trying to achieve the following:

  • Display all records where Category= General at the top.
  • After that, show records from other Category.
  • Within each Category, the Order field should be sorted alphabetically (A to Z) and Inactive is false.

Has anyone implemented a similar sorting logic or have suggestions on how to achieve this in a list view or through scripting?

Thanks in advance!

Avee90_0-1751262813684.pngAvee90_1-1751262862559.png

 

20 REPLIES 20

Hi @Avee90 

 

Can you explain a bit more in details?

 

So as per initial image, you want to get general at top, and remaining catagory below right?

 

Now what is this Sequence No1 and Sequence No2 field?

 

Or is it Category and Sub-Category setup

 

Like General and its sub-cat is: ABC, XYZ, DEF
so you want general at top and ABC, XYZ and DEF also based on order?

 

and same way with other category as well?

The table having 4 fields -1) Catgoery(Choice field: General, Network, Application, Software and Password), 2) Sequence No1(String: User can give 1-5 values) 3) Sequence No2(String: User can give 1-5 values) and 4) Inactive field(Active/Inactive)

So, There will be 150 records which have diff categories with Sequence No1 and No2(1-5).
I need to show General records at the top with those records should sort with Sequence No1 and Sequence No2 
Ex: 1st record: Category - General, Sequence No 1 - '1', Sequence No 2 - '1'
2nd record: Category - General, Sequence No 1 - '1', Sequence No 2 - '2'
2nd record: Category - General, Sequence No 1 - '2', Sequence No 2 - '1'
.

.

.
Category - Network, Sequence No 1 - '2', Sequence No 2 - '1

Below are the records with values




Avee90_0-1751278653588.png

 

@Avee90  it should show as category field choice itself?

 

Also You need to do this by creating script include and call it in dictionary record or client script

 

 

 

@Avee90 

at dictionary level you can add the sorting

is that a choice field with those many choices?

check this

Choices in a Select choice field are sorted alphabetically instead of according to their sequence va... 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

GlideFather
Tera Patron

Hi @Avee90
Do you have a list of values that will be static or the list is going to be updated in time?

If the first option, you can do the order manually but if new and new records will be created, existing updated (e.g. renamed) and/or deleted, then it will be too messy.

You might need to create a new field that would be hidden and in that field you can help the ordering, but it is already overkill just simply thinking about it.

And what about connect the two field into one?
"Category - Value":

"General - Network"
"General - Server"
"Password - Access"
"Application - SNUtils"

Ooooooor last idea - set the field as "Name-Value pair" type maybe (not tested, just an idea)
https://www.servicenow.com/docs/bundle/washingtondc-platform-administration/page/administer/field-ad...

Let me know how it goes..

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */