How to sort records in recordlist variable?

How to sort records in recordlist variable?

  

Hello,

I have created recordlist by appending records.

Now I am giving that recordlist variable as source source to TableRecords widget. But at the time of displaying records, I want to sort by default descending order of created date.

How do I achieve this?

Please advice.

Thanks and Regards,

Suraj Borade

Solution

Hi Suraj,

there is a component available in forge Sort Record List , i think this will help you achieve what you want.


Regards

-PJ-

Solution

Thanks Pramod

Hi Suraj,
Please mark ait as solution if it what you want ..This will help other also.



Regards

-PJ-

The problem with this solution is that it expects an Object, not a record list. If you have multiple entities in your recordset (i.e., customers and orders), I think it will lose the record definitions if made an object. Is this correct?

thanks,

Stephanie



Hi Stephanie,

Try ToObject(recordlist) and doing this it will not lose any defination.



Regards

-PJ-

Hi Stephanie,

Under the hood, OutSystems record lists are also Objects (Java or .NET). The SortRecordList extension uses a mechanism called reflection to inspect what's actually inside the generic Object, and thus can sort the list as you specify. There's nothing lost (otherwise the extension would be a bit useless :))!

Agreed with Killan.


Regards

-PJ-

Thanks for the tip, PJ. How do you then bind the results of the sort record list to a Table Records object?


Here is what I have:

- Aggregate with the results of 4 joined tables

- Convert this record list to an object

- SortRecordList on the object

Next?

thanks,

Stephanie

Hi Stephanie,

SortRecordList sorts the record list in place (as you may notice from the fact it doesn't have an output parameter). This means that after the call to SortRecordList, your original record is sorted. In the case of a TableRecords, rebinding occurs when you Ajax Refresh it (this also means you always need to sort the source list, then Ajax Refresh, instead of sorting the TableRecords.List, since after refreshing the TableRecords, the changes will be lost).