Skip to main content

Get unit conversion value of item in Ax 2012

To Get unit conversion value of item in Ax 2012 you can use below code. UnitOfMeasureConverter_Product is a class which has different method to give you converted value.

Here example is showing to get conversion value from liter to kilo gram.

 UnitOfMeasureConverter_Product unitConverter  = UnitOfMeasureConverter_Product::construct();  
 unitConverter.parmProduct(InventTable::find("TestIte",true).Product);  
 unitConverter.parmFromUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol("ltr"));  
 unitConverter.parmToUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol("kg"));  
 unitConverter.parmRoundAbsoluteValue(NoYes::Yes);  
 unitConverter.parmApplyRounding(NoYes::Yes);  
   info(strFmt("%1",unitConverter.convertValue(1)));  

Popular posts from this blog

X++ Code to run SSRS Report with parameter in D365 F&O (Example Sales Invoice )

Below is sample X++ Code to run SSRS Report with parameter in D365 F&O (Example Sales Invoice )      Args                       args = new Args();     CustInvoiceJour            custInvoiceJour;     SalesInvoiceJournalPrint   salesInvoiceJournalPrint;       select firstonly custInvoiceJour where custInvoiceJour.SalesId != '';       // Add record to be printed.     // In order to have the context table we need to set args.record().     args.record(custInvoiceJour);       salesInvoiceController = new SalesInvoiceController();     salesInvoiceController.parmReportName(         PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderInvoice).getDefaultReportFormat());       salesInvoiceContract = salesInvoiceController.parmReportContrac...