InventDim to retail variant

static void InventDim2RetailVariant(Args _args)
{
    InventDim                   inventDim;
    InventDimCombination        inventDimCombination;
    
    // define inventory dimensions
    
    inventDim           = InventDim::findDim(inventDim);
    inventDimCombination= InventDimCombination::find(itemId, inventDim.inventDimId);
    
    // inventDimCombination.RetailVariantId or inventDimCombination.DistinctProductVariant
}
It is crucial to get only product related dimmensions:
    InventDim                   inventDim = InventDim::find(_salesLine.InventDimId),
                                productInventDim;
    ListEnumerator              le;
    FieldId                     fieldId;

    le = InventDimGroupSetup::newItemIdProductDimensionsOnly(_salesLine.ItemId).activeFields().getEnumerator();
    while (le.moveNext())
    {
        fieldId = le.current();
        productInventDim.(fieldId) = inventDim.(fieldId);
    }
    productInventDim = inventDim::findOrCreate(productInventDim);
    // productInventDim.inventDimId
Or
    InventDim                           inventDim,
                                        productInventDim;
    InventDimGroupSetup                 inventDimGroupSetup;
	
    inventDimGroupSetup     = InventDimGroupSetup::newInventTable(inventTable);
    inventDim               = inventDim::find(_salesLine.InventDimId);
    inventDim.clearNotProductDim(inventDimGroupSetup);
    productInventDim        = inventDim::findDim(inventDim);
    // productInventDim.inventDimId

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags