Dynamics AX – Unit of Measure conversions(Intra/Inter) and X++

By Sourabh Khosla | July 8, 2014

So, recently I was working on a requirement where I had to fetch the Unit of Measures for each Item. (I would  leave the details on why and would rather focus on How ).

For those folks who are not much aware about the Unit of Measure conversions that AX offers, I'd suggest reading through this MSDN article : Unit conversions .  So, summarizing what the article says is basically that AX offers three different conversions viz. Standard(basically inch to cm, kg to gms etc.), Intra(e.g. pieces to boxes), Inter(e.g. kg to liter). Intra and Inter offer product specific Unit conversions, and that's what it makes them more special. In this post we will talk about how to fetch them based off an item.

while select * from unitOfMeasureConversion
where inventTableUnitConversion.ItemId == _itemId  // based on the itemId
&& unitOfMeasureConversion.Product == inventTableUnitConversion.Product
{
toUnitOfMeasure = UnitOfMeasure::find(unitOfMeasureConversion.ToUnitOfMeasure).Symbol;
fromUnitOfMeasure = UnitOfMeasure::find(unitOfMeasureConversion.FromUnitOfMeasure).Symbol;

if(toUnitOfMeasure && fromUnitOfMeasure)
{
if (UnitOfMeasure::find(unitOfMeasureConversion.FromUnitOfMeasure).UnitOfMeasureClass != UnitOfMeasure::find(unitOfMeasureConversion.ToUnitOfMeasure).UnitOfMeasureClass)
unitConversionInter = this.formatQuickFormula(unitOfMeasureConversion.InnerOffset, unitOfMeasureConversion.Factor, unitOfMeasureConversion.Numerator, unitOfMeasureConversion.Denominator, unitOfMeasureConversion.OuterOffset, toUnitOfMeasure, fromUnitOfMeasure);

if (UnitOfMeasure::find(unitOfMeasureConversion.FromUnitOfMeasure).UnitOfMeasureClass == UnitOfMeasure::find(unitOfMeasureConversion.ToUnitOfMeasure).UnitOfMeasureClass)
unitConversionIntra = this.formatQuickFormula(unitOfMeasureConversion.InnerOffset, unitOfMeasureConversion.Factor, unitOfMeasureConversion.Numerator, unitOfMeasureConversion.Denominator, unitOfMeasureConversion.OuterOffset, toUnitOfMeasure, fromUnitOfMeasure);
}
}

Well, that's all I have for this post. As always for any follow up questions/concerns you can always reach out at : sourabh@stoneridgesoftware.com


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!