I guess that with AX 2012 it is easier to create and release a product by using X++ code, but it is possibile to obtain the same result with AX7 (or dynamics 365 if you prefer).
The idea is to use the product data entity (i.e. EcoResProductEntity) and some standard - long named - classes.
Here is the code:
EcoResProductEntity ecoResProductEntity;
EcoResProductEntityToCrossTableDataAdaptor adaptor;
EcoResProduct product;
NumberSequenceReference numberSequenceReference = EcoResProductParameters::numRefProductNumber();
NumberSequenceTable numberSequenceTable = numberSequenceReference.numberSequenceTable();
Args args;
NumberSeq numberSeq = NumberSeq::newGetNumFromId(numberSequenceTable.RecId);
EcoResProductReleaseSessionManager productReleaseSessionManager;
EcoResReleaseSessionRecId releaseSessionRecId;
CompanyInfo companyInfo = CompanyInfo::find();
ecoResProductEntity.ProductNumber = numberSeq.num();
ecoResProductEntity.ProductSearchName = "myItem";
ecoResProductEntity.ProductName = "My Item";
ecoResProductEntity.ProductType = EcoResProductType::Item;
ecoResProductEntity.ProductSubType = EcoResProductSubtype::ProductMaster;
ecoResProductEntity.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::PredefinedVariants;
ecoResProductEntity.ProductDimensionGroupName = "Prod_Dim";
// here you can set all the fields of the data entity that you need
adaptor = EcoResProductEntityToCrossTableDataAdaptor::newFromEntity(ecoResProductEntity);
ttsbegin;
product = EcoResProductCrossTableManager::makeProductRecord(adaptor);
EcoResProductCrossTableManager::insert(adaptor, product);
// here you can create one or more translations
EcoResProductTranslation::createOrUpdateTranslation(product.RecId, "it translation", '', "it");
// now we want to release that master product for the current company
productReleaseSessionManager = EcoResProductReleaseSessionManager::newReleaseSession();
releaseSessionRecId = productReleaseSessionManager.parmReleaseSessionRecId();
productReleaseSessionManager.addProduct(product.RecId);
productReleaseSessionManager.addLegalEntityForProduct(companyInfo.RecId, product.RecId);
args = new Args(formStr(EcoResProductRelease));
args.record(EcoResReleaseSession::find(releaseSessionRecId));
// the first boolean parameter is for showing a log for errors
// the second boolean parameter is for executing the release with a batch
if (EcoResProductReleaseSessionBatch::runJob(args, true, false))
{
productReleaseSessionManager.cleanUp();
}
ttscommit;
I hope it can help you