How to get on hand inventory (quantity) of an item using x++


How to get on hand inventory (quantity) of an item using x++

In Microsoft Dynamics 365 Finance and Operations (D365 FO), you can use the below x++ codes for getting on hand inventory (quantity) of an item. Here you need to pass the two arguments ItemId and  InventDimId. You can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

public InventQtyAvailPhysical onHandInventory(ItemId _itemId, InventDimId _inventDimId)


    InventOnhand    inventOnhand;

    InventDim       inventDim = inventDim::find(_inventDimId);

    InventDimParm   inventDimParm; 


    inventOnhand = InventOnhand::newParameters(_itemId, inventDim, inventDimParm);

    return inventOnhand.availPhysical();


When we pass the _itemId and _inventDimId values to the function, the method availPhysical(); returns the  on hand inventory (quantity) of the item.

Post a Comment

Post a Comment
To Top