Application Development and Automation 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: 
Read only

odata v2 sorting not working (Java v1 backend service)

WFlats
Participant
0 Likes
1,176

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.

1 ACCEPTED SOLUTION
Read only

WFlats
Participant
0 Likes
1,058

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...

2 REPLIES 2
Read only

subhajit
Active Participant
1,058

Hello,

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

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

Read only

WFlats
Participant
0 Likes
1,059

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...