Default Sort for Related Lists

zschneider
Kilo Expert

anyone have any idea how to set up the default sort for a related list? I've found how to do it for all global tables, and I know how to sort via string queries. But neither of these apply for Related Lists.

Thanks,
Zach S.

12 REPLIES 12

DrewW
Mega Sage
Mega Sage

Well when I look under User preferences and then change the sort order of the incident's related list we have I see the following user preferences created and the incident list is also sorted the same.

incident.db.order.direction
incident.db.order

So the system must be using these user preferences to sort the the incident table no mater how it is displayed.


joeyleahy
Tera Contributor

Expanding on Drew's point that User Preferences are where you can set the sort order:
Most of the table will be for the user's settings but if you leave the "User" field blank it will apply the Preference to everyone in the system.

eg. Create 2 entries in User Preference table:
Name: incident.db.order.direction
System: true
Type: string
User: BLANK
Value: ASC

Name: incident.db.order
System: true
Type: string
User: BLANK
Value: short_description

Remove any other entries with the same name in the User Preference table to force this sort for all users.
Values for db.order.direction are ASC and DESC.


MG Casey
Mega Sage

I need a way to force a related list to be sorted a certain way no matter what the user preferences are.



Any ideas? There doesn't seem to be a way to do that in Fuji.


Never mind - I think I found a good workaround that forces a sort on a related list and prevent users from changing the sort order:



  1. Go to Relationships under System Definition.
  2. Click New.
  3. On the Applies to table field, pick your desired table that you want the related list to appear on.
  4. On the Queries from table field, pick the table to pull data from.
  5. In the Name field, pick a name for your Related List.
  6. In the Query with box, input your query. Example:

    current.addQuery('u_account', parent.sys_id);

    current.orderBy('state');
    current.orderByDesc('sys_updated_on');
    • The first line establishes the connection between the two tables.
    • The following two lines establishes my desired sort order.


This seems to work!