Hello Dynamics Community,
I've been struggling for a few days trying to find a reliable way to fetch inventory stock levels by item variant, and I'm hoping someone here has a solution.
My Goal:
I need to get the current inventory stock (e.g., quantity on hand, or projected available balance) for each specific variant of an item (e.g., Item "TSHIRT", Variant "RED", Variant "BLUE").
What I Have Tested So Far:
-
API v2.0 /items?$expand=itemVariants and /item and /itemVariants
-
API v2.0 /itemLedgerEntries
-
My plan was to calculate the stock myself by summing the quantity from this endpoint.
-
The Problem: The itemLedgerEntries response only includes the parent itemNumber. It's missing the variantId or variantCode field, which makes it impossible to link a ledger entry to its specific variant.
-
ODataV4 Endpoints
-
I have inspected several standard OData pages (like ItemLedgerEntries, PostedSalesShipments, etc.), but they all seem to have the same limitation.
My Constraint (Important):
I am building an integration that needs to be scalable for multiple clients. Therefore, I cannot deploy custom AL code (like a custom API page or query) to the client's environment. The solution must use the standard, out-of-the-box API or OData endpoints.
My Question:
Is there a standard API or OData endpoint that I'm missing? How can I get the inventory stock for each specific item variant without writing custom code?
Thank you in advance for your help!