Hi,
AX UOM Conversion - Convert Qty from a Unit to another Unit in AX
Try below code
Qty convertQty(Qty _qty, UnitOfMeasureSymbol _fromUnitId, UnitOfMeasureSymbol _toUnitId, ItemId _itemId)
{
//Return value after applying rounding on decimal precision defined on unit.
_qty = UnitOfMeasureConverter::convert(_qty,UnitOfMeasure::findBySymbol(_fromUnitId).RecId,UnitOfMeasure::findBySymbol(_toUnitId).RecId,NoYes::Yes);
return _qty;
}
OR
Try below code
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)));
OR
Using SELECT Statement
select unitOfMeasureConversion
where unitOfMeasureConversion.FromUnitOfMeasure==UnitOfMeasure::unitOfMeasureIdBySymbol("Lbs") &&
unitOfMeasureConversion.ToUnitOfMeasure==UnitOfMeasure::unitOfMeasureIdBySymbol("Gr") &&
unitOfMeasureConversion.Rounding==UnitOfMeasureConversionRounding::Nearest;
Print unitOfMeasureConversion.Factor;
AX UOM Conversion - Convert Qty from a Unit to another Unit in AX
Try below code
Qty convertQty(Qty _qty, UnitOfMeasureSymbol _fromUnitId, UnitOfMeasureSymbol _toUnitId, ItemId _itemId)
{
//Return value after applying rounding on decimal precision defined on unit.
_qty = UnitOfMeasureConverter::convert(_qty,UnitOfMeasure::findBySymbol(_fromUnitId).RecId,UnitOfMeasure::findBySymbol(_toUnitId).RecId,NoYes::Yes);
return _qty;
}
OR
Try below code
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)));
OR
Using SELECT Statement
select unitOfMeasureConversion
where unitOfMeasureConversion.FromUnitOfMeasure==UnitOfMeasure::unitOfMeasureIdBySymbol("Lbs") &&
unitOfMeasureConversion.ToUnitOfMeasure==UnitOfMeasure::unitOfMeasureIdBySymbol("Gr") &&
unitOfMeasureConversion.Rounding==UnitOfMeasureConversionRounding::Nearest;
Print unitOfMeasureConversion.Factor;
Comments
Post a Comment