Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Unanswered

Why when i use $orderby parameter in my custom API GET request my results get filtered?

(0) ShareShare
ReportReport
Posted on by

I have a custom API in Business Central on the Item Ledger Entry, and I added a piece of code that generate a random hardcoded value for the systemModifiedAt field (some record were missing it).

The code works well without $orderby parameter (retrieve the right data) however as soon as i add the $orderby parameter i only get one record for the hardcoded values (the first one). Also the results pass from 41.87MB to 41.79MB showing that something get filter.

Any idea why does it behave as such?

Here the piece of code i have in Visual Studio in AL in the itemLedgerEntries API Page:

       }        trigger OnAfterGetRecord()        var            TempSystemModifiedAt: DateTime;        begin            // Check if the SystemModifiedAt field is empty (0DT represents empty date and time)            if Rec.SystemModifiedAt = 0DT then begin                // If it's empty, manually set the date and time components                TempSystemModifiedAt := CREATEDATETIME(20191231D, 080000.075T);                    TempSystemModifiedAt := TempSystemModifiedAt + Random(5555555); // Add random number to the TempSystemModifiedAt                    Rec.SystemModifiedAt := TempSystemModifiedAt;            end;        end;         }

Here the result I get when using the $orderby parameter: /enter

And here the result I get when not ordering: Screenshot 1: /enter

Screenshot 2: /enter

Please let me know if someone has some ideas or assumptions, ChatGdp has none or not the right one haha :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans