Monday, June 3, 2013

How to create Inventory Dimension in AX 2012 using X++ Code

InventDimId createInventDim(ItemId                       _itemId,
                                   InventBatchId                _inventBatchId,
                                   WMSLocationId                _wmsLocationId,
                                   WMSPalletId                  _wmsPalletId,
                                   InventSerialId               _inventSerialId,
                                   InventLocationId             _inventLocationId,
                                   EcoResItemConfigurationName  _configId,
                                   EcoResItemSizeName           _inventSizeId,
                                   EcoResItemColorName          _inventColorId,
                                   InventSiteId                 _inventSiteId
                                   )
{
    InventTable item = InventTable::find(_itemId);
    InventDim   inventDim;
    ;
    #InventDimDevelop
    inventDim.InventBatchId     = _inventBatchId;
    inventDim.wmsLocationId     = _wmsLocationId;
    inventDim.wmsPalletId       = _wmsPalletId;
    inventDim.InventSerialId    = _inventSerialId;
    inventDim.InventLocationId  = _inventLocationId;

    if(item.configActive())
    {
        inventDim.ConfigId          = _configId;
    }
    if(item.sizeActive())
    {
        inventDim.InventSizeId      = _inventSizeId;
    }
    if(item.colorActive())
    {
        inventDim.InventColorId     = _inventColorId;
    }
    inventDim.InventSiteId      = _inventSiteId;
    inventDim.initFromInventLocation(inventDim.inventLocation());
    inventDim = InventDim::findOrCreate(inventDim);
    return inventDim.InventDimId;
}

No comments:

Post a Comment