UnitOfMeasureConverter::convert() method is depreciated

Message: BP Rule: [BPDeprecatedUOMProductParameter]:BPDeprecatedUOMProductParameter: The product parameter in UnitOfMeasureConverter class method 'convert' is deprecated, use the EcoResProductUnitConverter class instead.

Original deprecated code:
                salesLine.SalesDeliverNow   = UnitOfMeasureConverter::convert(
                        salesLine.InventDeliverNow,
                        UnitOfMeasure::unitOfMeasureIdBySymbol(salesLine.inventTable().inventUnitId()),
                        UnitOfMeasure::unitOfMeasureIdBySymbol(salesLine.SalesUnit),
                        NoYes::Yes,
                        InventTable::itemProduct(salesLine.ItemId));

Used to convert quantity from invent to sales. Replacement using EcoResProductUnitConverter class:
                salesLine.SalesDeliverNow       = EcoResProductUnitConverter::convertGivenUnitSymbolsForReleasedProduct(
                        salesLine.ItemId,
                        salesLine.InventDimId,
                        salesLine.InventDeliverNow,
                        salesLine.inventTable().inventUnitId(),
                        salesLine.SalesUnit,
                        NoYes::Yes);

Reference: smmSalesCustItemStatisticsDP.unitConvertValue() class:
    public Qty unitConvertValue(
        ItemId                  _itemId,
        InventDimId             _inventDimId,
        ModuleInventPurchSales  _module,
        UnitOfMeasureSymbol     _unitFrom,
        Qty                     _value = 1)
    {
        UnitOfMeasureSymbol unitTo = InventTableModule::find(_itemId, _module).UnitId;

        if (_unitFrom != unitTo)
        {
            UnitOfMeasureSymbol unitInvent  = InventTableModule::find(_itemId, ModuleInventPurchSales::Invent).UnitId;

            EcoResProductUnitConverter productUnitConverter = EcoResProductUnitConverter::newGivenUnitSymbolsForReleasedProduct(
                                                                                                _itemId, 
                                                                                                _inventDimId, 
                                                                                                _unitFrom,
                                                                                                unitInvent, 
                                                                                                NoYes::Yes);

            InventQty inventQty = productUnitConverter.convertValue(_value);

            productUnitConverter.parmFromUnitOfMeasureSymbol(unitInvent);
            productUnitConverter.parmToUnitOfMeasureSymbol(unitTo);

            return productUnitConverter.convertValue(inventQty);
        }

        return _value;
    }


 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags