D365 Business Central: How to Fix Missing Sales Invoices in the API

Business Central has many existing APIs that we can use, one of which is the Sales Invoices API. The API for Sales Invoices is based on the table called Sales Invoice Entity Aggregate.
This table consolidates data from:
- Unposted Sales Invoices (Sales Header)
- Posted Sales Invoices (Sales Invoice Header)
This API provides a single API endpoint that returns both posted and unposted invoices.
Recently, we had an issue with missing invoices in the API. If invoices are missing, the most likely cause is that the Sales Invoice Entity Aggregate table didn’t update properly. To fix this, we can run the API Data Upgrade process.

Go to the API Data Upgrade List page in Business Central. Find the relevant record: SALES INVOICES, and click Schedule Upgrades. This will automatically create a Job Queue Entry for the upgrade.



Schedule the Job Queue Entry. It’s recommended to run it outside business hours.
Once the job queue is finished, the API should return the missing invoices.
