Wednesday 1 August 2012

AX2012: X++ Code to verify active inventory dimensions on an item


Recently I came across a situation where I needed to validate if the inventory dimension "PalletId" is active on an item or not. After a little digging here and there, came across this piece of standard AX code to identify if an inventory dimension is active or not. It is always good to re-use standard AX code instead of writing our own logic. This helps in maintaining the quality of the code.


   InventTable     inventTable;
   InventDimParm   inventDimParm;
   ;
   inventTable   = InventTable::find('1000');
   inventDimParm =  InventDimParm::activeDimFlag(InventDimGroupSetup::newInventTable(inventTable));
   if(inventDimParm.WMSPalletIdFlag)
   {
       info("Pallet Enabled");
   }

Similarly we can validate other inventory dimensions as well.