web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Create product variants specific to product dimension values using X++ (D365 for operations)

Muhammad Yasir Profile Picture Muhammad Yasir 1,023
Hi guys,

Back again after so long. Today i will show you how to create specific product variants from X++ code. Many a times we import products and related product dimensions into AX. Then upon creating and releasing the variants, all the possible combination of the product dimension are created into the system.Some time there is no need to create all combinations of variants instead we just use few of them in our daily routine thus having an extra burden on the database.To get rid of those unused/irrelevant variants, we need to create only specific variants that serve our purpose. So here is the code snippet that will create product variants specific to the provided product dimension values.

Code Snippet

    Container                       dimensionValues;
    EcoResSizeName          size                   = "Large" ;
    EcoResColorName        color                  = "Red" ;
    EcoResProductNumber productNumber = "ITEM-001" ;

    //Container to hold dimension values - here used only specific dimension size and color.
    dimensionValues = EcoResProductVariantDimValue::getDimensionValuesContainer("", size, color,"");
   
    //Create Product variant with Product and dimensions provided
    EcoResProductVariantManager::createProductVariant(EcoResProduct::findByProductNumber(productNumber).RecId, EcoResProduct::findByProductNumber(productNumber).SearchName, dimensionValues);

Happy DAXing



This was originally posted here.

Comments

*This post is locked for comments