Notifications

176 views

Issue

Description

When "Reset to column defaults" is selected to reset a personalized list view to the default layout, the sort column and direction are not included. This can be confusing for users if they had sorted on a column that is not part of the default layout. The list would appear to not be sorted by any column.

The "Reset to column defaults" action calls the script include UIPage. Line 19 initiates the reset process which consists of several calls to other script includes and back end classes.

Unfortunately, this logic does not affect the sys_user_preference records related to the sort column and direction. The preferences are <table_name>.db.order and <table_name>.db.order.direction.

 

Procedure

*** Customization Disclaimer ***

The following procedure describes an unsupported customization. Please utilize with care and always test first in sub-prod.

 

The UIPage script include can be modified to set the sort preferences when it resets to the default list layout. This sample code starts at line 19:

Before

else
  v.reset(this.getParameter('sysparm_table'));

After

else {
  v.reset(this.getParameter('sysparm_table'));
     
  var tbl = this.getParameter('sysparm_table');
  
  // If we're resetting the Incident table
  if ( tbl == 'incident' ) {

    // Set the sort column user preferences to the default values
    gs.getUser().setPreference( tbl + '.db.order', 'number');
    gs.getUser().setPreference( tbl + '.db.order.direction', 'DESC');
  }
}

Call a separate script include

The above example sets the sort column to number when the incident table is reset to the default layout. To apply this functionality to multiple tables, a more manageable approach would be to move this logic into its own script include which can then be called from this script include:

else {
  v.reset(this.getParameter('sysparm_table'));
  
  var sortReset = new tableSortReset();
  sortReset.checkTable( this.getParameter('sysparm_table'));
}

Applicable Versions

Tested in Madrid

 

Article Information

Last Updated:2019-08-02 20:43:46
Published:2019-05-14