Control Default Sort Order of Reference List and restrict it

Ak Islam
Giga Contributor

Hi Community,

Seems like doing following does the job except I need to restrict the sort as well

2.3 Default sort order

The system automatically sorts lists that meet one of the sort order criteria.

If there is a user preference specifying the sort order for the table, the system sorts by the field listed in the user preference.

If the table is the Task table or any of its extensions, the system sorts by the Number field.

If the table contains a field with the attribute isOrder=true, the system sorts by this field.

If the table contains an Order field, the system sorts by this field.

If the table contains a Number field, the system sorts by this field.

If the table contains a Name field, the system sorts by this field

is there a way I can restrict reference column once sorted?

Thanks in advance

AK

5 REPLIES 5

snehabinani26
Tera Guru

4 Setting the Default Sort Order in the System Dictionary

Important: The defaultsort setting might not work as expected. A product defect has been opened to address this issue. See KB0547835.


An administrator can set the sort order of records displayed for a table in the System Dictionary when there is no other sort specified. This is the sort order presented to all users initially. Once a user sorts a list, that user preference is saved, and the list is always sorted for that user based on the previous sorting preference.



Hope this helps you


Shishir Srivast
Mega Sage

Hi Amdadl,



Please refer below link. Thank you!


Controlling the Sort Sequence Used to Display Lists - ServiceNow Wiki


shloke04
Kilo Patron

Hi,



Can you try writing a Before query Business Rule on the Reference Table to restrict the sorting for the other users with the default sort available for all done by the Admin in the script:



Please create a Before Query business Rule on the Reference Table. For example In the below script I have restricted the sorting i.e. the latest created records would always be at the top for all the Users on the project Table:



Script:



(function executeRule(current, previous /*null when async*/) {




  // Add your code here


  var query = 'ORDERBYDESCsys_created_on';


  current.addEncodedQuery(query);





})(current, previous);



find_real_file.png



find_real_file.png



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi,



If your query is Resolved please mark the answer as correct and close the thread.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke