X++ Code to Create and Release a Product in D365 F&O

Hello everyone,

Today I came across a requirement for Creating and Releasing a Product in D365 FO. Earlier version Ax 2012 has a lot of class's to achieve the requirement but those got deprecated and below is the new way(at least for me) to achieve the requirement.

Args args;
EcoResProductEntity ecoResProductEntity;
EcoResProductEntityToCrossTableDataAdaptor adaptor;
EcoResProduct product;
EcoResProductReleaseSessionManager productReleaseSessionManager;
EcoResReleaseSessionRecId releaseSessionRecId;
NumberSequenceReference numberSequenceReference = EcoResProductParameters::numRefProductNumber();
NumberSequenceTable numberSequenceTable = numberSequenceReference.numberSequenceTable();
NumberSeq numberSeq = NumberSeq::newGetNumFromId(numberSequenceTable.RecId);
CompanyInfo companyInfo = CompanyInfo::find();