/ Microsoft / Get on hand inventory (quantity) of an item using x++

Get on hand inventory (quantity) of an item using x++

Learn, share and spread knowledge

To get on hand inventory (quantity) of an item using x++ in Microsoft Dynamics 365 for Finance and Operations or in Microsoft Dynamics AX 2012 is always a headache because there is no field in the table which gives the on hand inventory. So, to tackle this issue I am sharing this function. It gets two arguments which are as follows:

  1. ItemId
  2. InventDimId

It returns on hand inventory.

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();

So, this is how you can get on hand inventory (quantity) of an item using x++ in D365FO or in AX 2012. Moreover, you can also explore more functions and tricks. Don’t forget to share your code in comments.

If this helps you, please Like, Comment and Share to help other people.

Blog: Click here

YouTube: Click here

GitHub: Click here

A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty. – Winston Churchill


Send Us A Message Here

Your email address will not be published. Required fields are marked *

NevoiTech Blog

A blog by Moeen Ahmed SultanNevoiTech logo

To hire freelancer or get personal training


Call/WhatsApp: +92 321 458 9595

Email: info@nevoitech.com