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:

I don’t wanna setup up this way
I want the default sort to be descending order on date entered by default

It remembers how you sorted it last time and becomes the default the next time you login or go back to the view.

how do I override that ?

Jest sort it again. The next time you go back it will be sorted the way you want it. If that doesn’t dobit for you youll have to code something. Maybe a custom list view.