microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
728 stars 241 forks source link

ODataV4 always provide the data in a Primary Key order from BC23 !!! #7624

Closed HegedusZsolt closed 8 months ago

HegedusZsolt commented 8 months ago

As we realized in BC23 release, if you are trying to retrieve data via ODataV4 protocol, you will got the data always in a primary key order. It does not matter you are setting a different sort order in a SourceTableView property or OnOpenPage trigger of the page.

If you run the page in a WebClient or retrieve the data via SOAP protocol it works well, you will got the data in a right order, and it worked with ODataV4 also till BC23.

Repro on CRONUS BC23:

  1. Create a simple list page, based on table Customer, with the two following fields No. and Name.
  2. Set sort by Name with a SourceTableView property or with a setcurrentkey statement in trigger OnOpenPage
  3. Run the page in the WebClient. You will got the customers by Name
  4. Publish the page as web service
  5. Click on an ODataV4 URL for this page and you will got the customers by No.

This "feature" breaks our app, so please handle this with priority.

SBalslev commented 8 months ago

Let's get the issue to a team who will fix and backport it, as this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.

SBalslev commented 8 months ago

Btw. OData spec says you should use the $orderby so I recommend trying that first.

HegedusZsolt commented 8 months ago

Btw. OData spec says you should use the $orderby so I recommend trying that first.

I know, but we would like to define sort order on a server side and using $orderby requires to extend our pages with those key fields, so it would be easier if it works as before.