AnsweredAssumed Answered

Set default sort order of a Dashlet list on the module record view for sugarcrm 7.x

Question asked by Julien Roussel on Jul 4, 2016
Latest reply on Jul 6, 2016 by Julien Roussel

Hello everyone,

 

I'm stuck on this basic problem for SugarCRM 7.X : How to change the default sort order of a Dashlet displayed on the Contact record view?

This problem seems very basic but I cannot find a way to solve it, maybe I'm missing a simple thing, but if a hero could help me find a way to solve it...

 

Here is what I tried without expected behaviour :

1. Create a custom component to work on the collection to apply the custom sort :

- custom-dashablelist component with proper reference in the dashboard table

{"components":[{"rows":[

[{"width":12,"context":{"module":"CustomModule","link":null},"view":"label":"CustomModule","type":"custom-dashablelist","module":"CustomModule", "last_state":{"id":"custom-dashable-list"},"intelligent":"1","limit":5,"filter_id":"all_records","display_columns":["name","related_name","custom_date"],"linked_fields":["related_module"],"skipFetch":true,"componentType":"view","link":null}}],

],"width":12}]}

1.a. Trying to sort the result collection from custom-dashablelist.js file :

this.collection.comparator = "custom_date";

this.collection.sort();

1.b. Trying to override list.js too :

collection.orderBy.field = "custom_date";

collection.orderBy.direction = 'desc';

2. Trying to override current order in Query with a before_fetch_query logic hook, but I cannot know that the query is from my specific Dashlet...

...

Outcomes