List view default sorting order

Hi experts,

My SuiteCRM version is 7.10.20

I want to configure a system-wide listview sorting order based on the DATE_ENTERED field and ASC.

All the CRM modules should have by default this order. Is there any way where I can make a change in one file and it gets applied to all CRM modules?

I have tried to make changes to this file. include\MVC\View\views\view.list.php in the function listViewPrepare()

$this->params['orderBy'] = 'date_entered';
$this->params['sortOrder'] = 'ASC';
$this->params['overrideOrder'] = true;

Thanks!

Hi.
Is this solution working for you or Not??

I don’t know of a way to do that globally. Those base classes sometimes are overriden in specific modules. And some times, they call the parent class, other times they just replicate the code in the override, and don’t call the parent. That might explain why your change isn’t taking effect sometimes…

No. It’s not taking effect.

Thanks!

function listViewPrepare() {
		if(!isset($_REQUEST['orderBy'])) {
			$_REQUEST['orderBy'] = 'date_entered';
		}
		if(!isset($_REQEUST['sortOrder']) {
			$_REQUEST['sortOrder'] = 'DESC';
		}
		parent::listViewPrepare();
	}

Try this. basically it may can work only if there is NO OTHER order by field is set.you can give it a try after clearing search filters and all filters for a module

If you want to respect user preferences then use the following code:

public function preDisplay()
{
   $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', 'AOK_KnowledgeBase2_AOK_KNOWLEDGEBASE'); // you can get required category name from "user_preferences" table. 

       if(empty($userPreferenceOrder['orderBy']))
        {
	      $_REQUEST['orderBy'] = 'field_name';
	      $_REQUEST['sortOrder'] = 'DESC';
         }

         parent::preDisplay();
    }

does this work for 2024 versions?