2

I am attempting to get the count of filtered OData results in a Fiori SAPUI5 application. I am able to get the correct count using both $count and $inlinecount in Postman using the following: MyEntitySet/$count?$filter=Id eq '9' and MyEntitySet?$filter=Id eq '9'&$inlinecount=allpages&$format=json.

However, when I try to use these query parameters in my UI5 code, I don't get the result I want.

myV2ODataModel.read("/MyEntitySet/$count?$filter=Id eq '9'", {/*...*/});

gives me the count of the unfiltered results, while

myV2ODataModel.read("/MyEntitySet?$filter=Id eq '9'&$inlinecount=allpages", {/*...*/});

gives me all the records, and I am unable to access the inline count.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Ui5 Dev
  • 23
  • 3

1 Answers1

2

Check the documented API reference for myV2ODataModel.read: https://sdk.openui5.org/api/sap.ui.model.odata.v2.ODataModel#methods/read

So it should be:

// Filter required from "sap/ui/model/Filter"
myV2ODataModel.read("/MyEntitySet/$count", {
  // ...,
  filters: [
    new Filter(/*...*/), 
  ],
}); 
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170