Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

odata v2 sorting not working (Java v1 backend service)

WFlats
Participant
0 Kudos

I want to find the earliest start of a task entity at a certain location with an odata v2 read operation.
This is the code

oModel.read("/Tasks", {
filters: [new Filter("location_ID", FilterOperator.EQ, sLocationID)],
sorter: [new Sorter("actualStart", false)],
urlParameters: {
$top: 100 // revisit
},
success: function (oData) {...

I usually only have to use "$top: 1" as this first entity contains the earliest task.

But I realised that the data is not sorted.

When I look at the HTTP request then the payload doesn't contain any "orderBy" statement.

SAP support told me to ask a question here as it is custom code.

Can anyone see an error in my code? I used such read operations with a sorter many times and can't see a mistake.

  • SAP Managed Tags:
1 ACCEPTED SOLUTION

WFlats
Participant
0 Kudos

Subhajit provided the corect answer in his comment. Thanks very much!

Not sure how many times I checked the code but couldn't see it...

  • SAP Managed Tags:
2 REPLIES 2

subhajit
Active Participant

Hello,

Replace the parameter name with ‘sorters’ instead of ‘sorter’..

Also make sure your alias points to the correct class..

  • SAP Managed Tags:

WFlats
Participant
0 Kudos

Subhajit provided the corect answer in his comment. Thanks very much!

Not sure how many times I checked the code but couldn't see it...

  • SAP Managed Tags: