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

Support The Author

 If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.

Buy Me a Coffee

Post a Comment


All Comments


No comments. Be the first one to comment on this post.

Search

About

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

Authors are allowed to set their own "buy me a coffee" link.
Join us.

Blog Tags