Wednesday, April 22, 2020

Unit conversions using X++ , Standard and Intra-class conversions in AX

Standard conversion

RefRecId unitOfMeasureFromRecId = UnitOfMeasure::findBySymbol(inventTable.salesUnitId()).RecId;
RefRecId unitOfMeasureToRecId = UnitOfMeasure::findBySymbol(salesLine.SalesUnit).RecId;

real defaultUnitConvertedQty =  UnitOfMeasureConverter::convert(abs(inventTrans.Qty),
                                                                           unitOfMeasureFromRecId,//from
                                                                           unitOfMeasureToRecId,//To
                                                                           NoYes::No);

Intra-class conversion

real unitConvertedQty = EcoResProductUnitConverter::convertGivenUnitSymbolsForReleasedProduct(inventTable.ItemId,
                                                                                                         salesLine.InventDimId,
                                                                                                         abs(inventTrans.Qty),
                                                                                                         inventTable.salesUnitId(),//from
                                                                                                         salesLine.SalesUnit,//To
                                                                                                         NoYes::No);

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8