4

I can get the return list from this query, but if I add the orderby syntax, it just ignores it (no error, just doesn't sort the return set).

http://<mysite>/_vti_bin/listdata.svc/Products?$filter=DeliveryFormat eq true&$orderby=Title desc
5
  • Is DeliveryFormat a boolean? Jan 29, 2013 at 9:08
  • yes. but it doesn't matter - if i just take it back to Products and try and order, it won't work ("http:///_vti_bin/listdata.svc/Products?$orderby=Title desc"). Jan 29, 2013 at 17:53
  • when i look at the service $metadata this is the property i'm trying to orderby -<Property Name="Title" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" /> Jan 29, 2013 at 18:04
  • 1
    This seems like a bug. I also tried it but orderby never works. Jan 31, 2013 at 14:56
  • not a bug, see my answer...
    – WhiteHat
    Aug 20, 2015 at 14:04

1 Answer 1

1

It depends on where you are reviewing the results.

If you're building the URL in the address bar of a browser, the results WILL NOT necessarily be sorted by the orderby parameter. That is because the "Displaying" section on the right side of the Atom feed results, in the browser, takes over. You can actually sort it right there on the screen by clicking the column labels under the "Sort by:" section.

However, if you submit the request via ajax or something in code and inspect the returned JSON, you will see that the results ARE sorted properly.

Results from my test, look for: "Title":"test 1" & "Title":"test 2" :

Test 1 - asc

LOG (url): //_vti_bin/ListData.svc/MD_App?$select=Id,Title,ModifiedBy,Modified&$orderby=Title asc

LOG (json): {"d":{"results":[{"__metadata":{"uri":"http:///_vti_bin/ListData.svc/MD_App(1)","etag":"W/\"1\"","type":"Microsoft.SharePoint.DataService.MD_AppItem"},"Id":1,"Title":"test 1","Modified":"2015-08-20T09:17:07.000Z","ModifiedBy":{"__deferred":{"uri":"http:///_vti_bin/ListData.svc/MD_App(1)/ModifiedBy"}}},{"__metadata":{"uri":"http:///_vti_bin/ListData.svc/MD_App(2)","etag":"W/\"1\"","type":"Microsoft.SharePoint.DataService.MD_AppItem"},"Id":2,"Title":"test 2","Modified":"2015-08-20T09:17:14.000Z","ModifiedBy":{"__deferred":{"uri":"http:///_vti_bin/ListData.svc/MD_App(2)/ModifiedBy"}}}]}}

Test 2 - desc

LOG (url): //_vti_bin/ListData.svc/MD_App?$select=Id,Title,ModifiedBy,Modified&$orderby=Title desc

LOG (json): {"d":{"results":[{"__metadata":{"uri":"http:///_vti_bin/ListData.svc/MD_App(2)","etag":"W/\"1\"","type":"Microsoft.SharePoint.DataService.MD_AppItem"},"Id":2,"Title":"test 2","Modified":"2015-08-20T09:17:14.000Z","ModifiedBy":{"__deferred":{"uri":"http:///_vti_bin/ListData.svc/MD_App(2)/ModifiedBy"}}},{"__metadata":{"uri":"http:///_vti_bin/ListData.svc/MD_App(1)","etag":"W/\"1\"","type":"Microsoft.SharePoint.DataService.MD_AppItem"},"Id":1,"Title":"test 1","Modified":"2015-08-20T09:17:07.000Z","ModifiedBy":{"__deferred":{"uri":"http:///_vti_bin/ListData.svc/MD_App(1)/ModifiedBy"}}}]}}

Test 3

To test in the browser, add this to the end of the URL: &$top=1

The following URL returns "Test 1":

//_vti_bin/ListData.svc/MD_App?$select=Id,Title,ModifiedBy,Modified&$orderby=Title asc&$top=1

While this one returns "Test 2":

//_vti_bin/ListData.svc/MD_App?$select=Id,Title,ModifiedBy,Modified&$orderby=Title desc&$top=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.