Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying more than one sort on a Tridion broker query

I have a broker query where I need to sort by 2 different fields (using JSP and 2011 SP1)

The API has the method "addSorting" which I am applying.

It appears, however, that the second addSorting call is overwriting the first addSorting call - rather than adding the second sort:

// Sort by Date
CustomMetaKeyColumn customMetaKeyColumnDate = new CustomMetaKeyColumn("date", MetadataType.DATE);
query.addSorting(new SortParameter(customMetaKeyColumnDate, SortParameter.DESCENDING));

// Sort by Owner
CustomMetaKeyColumn customMetaKeyColumnOwner = new CustomMetaKeyColumn("owner", MetadataType.STRING);
query.addSorting(new SortParameter(customMetaKeyColumnOwner, SortParameter.ASCENDING));                 

They sorts work fine individually.

Is this expected? Is addSorting really a setSorting - where only 1 sort can be specified or am I missing a way to combine 2 sorts?

like image 371
Jonathan Avatar asked Jun 27 '12 14:06

Jonathan


1 Answers

The addSorting method works just fine. However, it simply does not work for CustomMeta columns!!! There is already a confirmed defect regarding this subject with the following summary: "SortParameter does not work with two metadata fields". This is still an open defect for 2011SP1 and is scheduled to be fixed only for the next release.

Cheers, Daniel.

like image 51
Daniel Neagu Avatar answered Nov 09 '22 09:11

Daniel Neagu