Sort order control

For any list, if the user has clicked a column header to sort by that column, then that action is remembered. The next time that list is displayed, the same field is used to order the list.

This remembered sort field can be overridden by adding a sysparm_order specification to the definition of the module. For example, if each time News is displayed, you want the new items listed in order of importance, then the News module can be updated accordingly.

Figure 1. Set module sort order to the Importance field value
Module arguments to set the sort order based on the Importance field

The actual order (ascending or descending) can be specified by adding a sysparm_order_direction specification. Here are two examples of sorting a list by the sys_created_on field, one ascending and one descending:

&sysparm_order=sys_created_on &sysparm_order_direction=desc
&sysparm_order=sys_created_on &sysparm_order_direction=asc

Sort by multiple fields

To sort a list by multiple fields, remove everything from the filter field and place it in the arguments field. For example, if the filter specifies [Active] [is] [true] and you want to sort by category and subcategory, remove the condition and put the following in the module arguments:

active=true^ORDERBYcategory^ORDERBYsubcategory

This argument first orders by the category and then orders by the subcategory. If you want any field to be a descending sort then change ORDERBY to be ORDERBYDESC.