Create product variants specific to product dimension values using X++ (D365 for operations)
Views (2479)
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
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.
*This post is locked for comments