Custom Sort on modules

Hi everybody!

Im trying to create a custom sort for the documents sub-panel and module, but without success,

some idea for do that?

i tryed this:

//check and set the default sort order
if (!isset($_REQUEST[‘sortOrder’]))
$_REQUEST[‘sortOrder’] = ‘DESC’;

but without success

any solution did you find to this?

It depends. Which version of SuiteCRM? I have a version 7 solution.

You just create a custom layout def and specify the sort order.

For example a subpanel in accounts:

custom/Extension/modules/Accounts/Ext/Layoutdefs/name of subpanel.php

I’m customizing the history subpanel, but you can do the same for any, here’s the relevant part of the code:

$layout_defs['Accounts']['subpanel_setup']['custom_activities'] = array(
    'order' => 55,
	'sort_order' => 'desc',
    'sort_by' => 'date_due',

This will specify a default sort order.

1 Like

Thank you for the solution! :heart_hands:

There may be easier ways of doing this by extending the layout_defs directly, but the above worked for me on a project I’m currently working on.

I want to do it for the list view instead

Just save a filter with a custom sort.

can you please provide with me an example

Setup the view the way you want and save it as a filter: