the default sort order of a new module is not using the date_entered column
Expected Behavior
when user did not selected any sort order clicking the arrows in the listing table header, the default sort should fallback to the date_entered property
OR there should be an easy way to define the default sort order of the module (column name, asc/desc)
Actual Behavior
I do have a custom module ✔️
In the listviewdefs.php I have configured available columns in the default list view ✔️
User can sort manually by clicking the small arrows next to the columns ✔️
According to the code I found in the LegacyFilterMapper.php in method getOrderBy there seems to be a fallback that looks like it should do the automatic fallback to the date_entered property, when nothing is provided
Unfortunatelly it is not true, bucause the ?? operator checks null, but the GQL request made from the default listview component provides an empty string, therefore the fallback never gets triggered ❌
Possible Fix
I was able to fix the intended behaviour by changing $result = $db->quote($sort['orderBy'] ?? 'date_entered'); to $result = !empty($db->quote($sort['orderBy'])) ? $db->quote($sort['orderBy']) : 'date_entered';
Steps to Reproduce
create a module
go to listview of the entities of the module
the default sorting is not according to the date_entered property
Context
Your Environment
SuiteCRM Version used: 8.2.4
Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Any
Environment name and version (e.g. MySQL, PHP 7): PHP 7.4
Issue
date_entered
columnExpected Behavior
date_entered
propertyActual Behavior
listviewdefs.php
I have configured available columns in the default list view ✔️LegacyFilterMapper.php
in methodgetOrderBy
there seems to be a fallback that looks like it should do the automatic fallback to thedate_entered
property, when nothing is provided??
operator checksnull
, but the GQL request made from the default listview component provides an empty string, therefore the fallback never gets triggered ❌Possible Fix
$result = $db->quote($sort['orderBy'] ?? 'date_entered');
to$result = !empty($db->quote($sort['orderBy'])) ? $db->quote($sort['orderBy']) : 'date_entered';
Steps to Reproduce
date_entered
propertyContext
Your Environment