Sunday, July 29, 2012

How to get onhand inventory?

A very common practice for a developer on day to day basis is to get on hand inventory based on different parameters (dimensions). I’ve came across a situation where I was getting this physical available from ‘InventSum’ table directly rather using ‘InventOnhand’ class and the result was different for some items. I think it would be better to use the InventOnHand class for querying on hand data. AX uses a secondary table called ‘InventSumDelta’ for capturing changes applied to the ‘inventSum’ that haven’t been committed yet. Not taking the ‘InventSumDelta’ in consideration can lead to unexpected results.
Here is the sample code snippet you can use for this purpose