web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Import UOM conversion per product

(0) ShareShare
ReportReport
Posted on by 928

Hello,

i need to import UOM conversion per product. i know that for D365 there is an entity called EcoResProductSpecificUnitOfMeasureConversionEntity: i didnt find it for AX 2012 R3.

any idea?

Regards,

David

*This post is locked for comments

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Not all DMF entities are available in AX 2012 , so you may have to create it.

  • David Tailor Profile Picture
    928 on at

    Hi,

    i found the following link how to modify UnitofMeasureEntity class to be able to upload unit of measure conversion per product.

    www.andesoft.net/upload-data-unitofmeasureconversion-dmfunitofmeasure

    however it is giving the following error on: findbysymbol:

    Argument '_symbol' is incompatible with the required type

    any idea?

    Regards,

    David

  • Mea_ Profile Picture
    60,286 on at

    Obviously when you added new field you used wrong data type. findBySymbol expects string and probably you trying to pass something that is not a string.

  • David Tailor Profile Picture
    928 on at

    I need a solution please.

    Anyone can help ?

    Regards,

    David

  • Suggested answer
    Sangram Shinde Profile Picture
    2,120 on at

    Hi David,

    A simple meaning of your error is the argument with name _symbol you are passing has some different type than what is expected. Please check and update exact required EDT for the field.

    By the way I didn't understand what are you passing exactly in _symbol argument, whereas looking at code it should be some field that you have added in your staging table.

    Please check or share your code/more details.

    Thanks,

    Sangram

  • David Tailor Profile Picture
    928 on at

    Hi Sangram,

    This is the code for generate method:

    public container GenerateUnitOfMeasureConversion()

    {

       container                   res;

       UnitOfMeasure               uomTo, uomFrom;

       EcoResProduct               ecoResProduct;

       UnitOfMeasureConversion     uomConversion;

       if(entity.ToUnitOfMeasure&& entity.FromUnitOfMeasure)

       {

           uomTo           =   UnitOfMeasure::findBySymbol(entity.ToUnitOfMeasure);

           uomFrom         =   UnitOfMeasure::findBySymbol(entity.FromUnitOfMeasure);

           ecoResProduct   =   EcoResProduct::findByDisplayProductNumber(entity.Product);

           if (uomTo.RecId && uomFrom.RecId)

           {

               uomConversion.Denominator       = entity.Denominator;

               uomConversion.FromUnitOfMeasure = uomFrom.RecId;

               uomConversion.Factor            = entity.Factor;

               uomConversion.ToUnitOfMeasure   = uomTo.RecId;

               uomConversion.Numerator         = entity.Numerator;

               uomConversion.Product           = ecoResProduct.RecId;

               uomConversion.insert();

           }

       }

       res = [uomConversion.RecId];

       return res;

    }

    and this is the code for getReturnFields:

    public static container getReturnFields(Name _entity, MethodName _name)

    {

       DataSourceName dataSourceName = queryDataSourceStr(DMFUnitOfMeasureTragetEntity,UnitOfMeasure);

       container      con            = [dataSourceName];

       Name fieldstrToTargetXML(FieldName _fieldName)

       {

           return DMFTargetXML::findEntityTargetField(_entity, dataSourceName, _fieldName).XMLField;

       }

       switch (_name)

       {

           case methodStr(DMFUnitOfMeasureEntityClass, GenerateUnitOfMeasure) :

           case methodStr(DMFUnitOfMeasureEntityClass, GenerateUnitOfMeasureW) :

           // <JDNaranjo>

           case methodStr(DMFUnitOfMeasureEntityClass, GenerateUnitOfMeasureConversion) :

           // </JDNaranjo>

               break;

           default:

               con = conNull();

       }

       return con;

    }

    Regards,

    David

  • Sangram Shinde Profile Picture
    2,120 on at

    Ok David, you are getting same error still? what EDT you have used for fields ToUnitOfMeasure and FromUnitOfMeasure fields?

    At these lines only you are getting the error, right?

    Thanks,

    Sangram

  • David Tailor Profile Picture
    928 on at

    EDT for toUnitOfMeasure and FromUnitOfMeasure are:

    UnitOfMeasureToRecId and UnitOfMeasureFromRecId respectively

    Regards,

    David

  • Suggested answer
    Sangram Shinde Profile Picture
    2,120 on at

    Ok,

    Here you have to change the EDT for these two fields in staging table, a method findBySymbol() itself saying to pass a symbol argument to this method and your fields are of type RecId(int64) so this is miss matching.

    Please try using 'UnitOfMeasureSymbol' EDT these two fields of your staging table.

    Thanks,

    Sangram

  • Sangram Shinde Profile Picture
    2,120 on at

    Or, delete these two fields from staging table, simply copy 'Symbol' field from 'UnitOfMeasure' table, paste in your staging table twice and rename them as ToUnitOfMeasure, FromUnitOfMeasure.

    Thanks,

    Sangram

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans