web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Filtering/sorting sales orders by LastModifiedDateTime has unexpected results

(1) ShareShare
ReportReport
Posted on by 8
Hey folks,
 
Just trying to debug an issue we have calling the Dynamics API for our app's BC integration.
 
We're trying to get all recently updates sales orders, using a call like this: https://api.businesscentral.dynamics.com/v2.0/<tenant-id>/<environment>/api/v2.0/companies(<company-id>)/salesOrders?$expand=SalesOrderLines&$filter=LastModifiedDateTime%20ge%202025-11-11T00%3A49%3A27.4600000Z&$orderBy=LastModifiedDateTime%20asc
 
For the most part, it works:
- Sales orders are returned in the order expected (last modified, ascending)
- No sales orders are returned with a last modified date LESS THAN the given date
 
The times are critical for us, as we use them to efficiently query, while ensuring that we don't miss any updates in BC.
 
HOWEVER
 
Sometimes, it doesn't work! And we get random results interleaved that violate the two invariants listed above. For example, here's the actual last modified dates pulled from that above request example.
 
2025-11-11T00:54:00.1830000Z,
2025-11-11T00:54:00.3700000Z,
2025-11-11T00:54:00.5170000Z,
2025-11-11T00:54:00.6430000Z,
2025-11-11T00:59:02.7170000Z,
2025-11-11T00:59:21.8200000Z,
2025-11-11T00:59:28.8000000Z,
2025-11-10T20:03:07.7170000Z,
2025-11-11T00:49:27.4600000Z,
2025-11-11T00:49:42.8830000Z,
2025-11-11T00:49:48.3000000Z,
2025-11-11T00:50:55.4430000Z,
 
You'll see that it's MOSTLY ascending. But then we get a record where it jumps back in time, and then continues from there again.
 
Can anyone explain this behaviour? We want to be able to figure out if there's a suitable workaround we can put in for this, but we can't do that unless we can pin down what the behaviour is. Another thing we've noticed, is that it seems like when we repeat the request again at a later date, the same collection of data becomes properly sorted, and there are no items that have a last modified date less than the requested one.

Thanks,
Michael
I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,351

#2
Sumit Singh Profile Picture

Sumit Singh 2,072

#3
YUN ZHU Profile Picture

YUN ZHU 1,807 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans