Thursday, March 17, 2016

Code for unit conversion of quantity

Hi guys,

Below is the sample code to convert quantity from one unit to another.


    RecId      fromUnit, toUnit;
    Qty         fromQty, toQty;
    ;
    fromQty   = 100;    
    fromUnit   = UnitOfMeasure::findBySymbol('KG').RecId;
    toUnit       = UnitOfMeasure::findBySymbol('g').RecId;    
    toQty       = UnitOfMeasureConverter::convert(fromQty, fromUnit, toUnit, false);
    
    info(strFmt("%1",toQty));

No comments:

Post a Comment