Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

List View sorting being removed

paulmagaling
Tera Contributor

We have a requirement where our list view should be in a fixed sorting when clicking the module to the asset task table. It was achieved, but I noticed a strange behavior.

paulmagaling_0-1787760663346.png

 

When one filter condition is being removed from the breadcrumbs, the sorting disappears. Is this a normal behavior?

paulmagaling_1-1787760735261.png

 

How can I make the sorting as constant or fixed state?

8 REPLIES 8

We've added sorting from the module's arguments already. But when we remove one of the filter conditions through the breadcrumbs, the sorting will be removed or disappear.

@paulmagaling could you possibly share before and after removing that part? it's difficult to imagine for me


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

When you open the custom module for the asset_task list view, a predefined query and sorting from the module's argument is used for the list view.

paulmagaling_0-1787920044257.png

After removing the contract end date filter directly from the breadcrumbs, sorting is gone or removed.

paulmagaling_1-1787920098749.png

Is this an out-of-the-box or expected behavior of the filter condition?

mohithreddy
Mega Contributor

What you are seeing is expected: a sort put in the module URL/filter is only the initial sort, and the platform then saves the user's own sort/filter preference per table+view, so on the next visit the personal preference wins and your "fixed" order disappears. Options to make it stick: 1) Put the order in the module itself - Module > Link type = List of Records, and add the sort to the Filter using the encoded query with ORDERBY, e.g. active=true^ORDERBYnumber (or ORDERBYDESCsys_created_on). This is stronger than setting it via the list header. 2) Make it the default for everyone by setting the order on the view: open the list, right-click the column header > Sort, then Right-click list header > Configure > List Control, or better set the default order on the table's list layout / use a Display Business Rule-free approach: sys_ui_list_control has no sort, so the reliable place is the module filter above. 3) If users' saved preferences are overriding it, clear them: sys_user_preference records named <table>_list.<view>.orderby and orderby_direction (and the sys_ui_list_control / list filter preferences). Delete for the affected users, or add a fix script to clear them. 4) For a guaranteed unchangeable order, build the module as a UI Page / interactive filter is overkill - instead point the module at a saved list filter (sys_filter) that includes ORDERBY, and mark the column non-sortable via dictionary attribute no_sort=true on the fields you do not want users re-sorting. Practical combo that works: module filter with ^ORDERBY + delete existing orderby user preferences for that table/view.