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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Unit convertion in Computed Column to use in Query

(0) ShareShare
ReportReport
Posted on by

Good day everyone, 

I am creating a form, which will be used for matching purchase and sales line.

This form needs to present the list of matching purchase candidates for a SalesLine comparing quantity with purchase lines.
From sales order form we can select the sales line and then click menu action button to open my form show matchable candidates.

This is a form with a grid and behind it is a query with a PurchLine as a main datasource.

The matching is done using quantity, when SalesLine.SalesQty == PurchLine.PurchQty we need to show this line, but, of course, lines can have different units and we need to implement unit conversion there.

For sales line with 100 * UnitId kilograms the form should show all PurchLines candidates which have 100 kg or even 0.1 ton or even 100 000 grams.

And that is a problem I do not know how to add the convertion to my form.

Unfortunatelly we need performance and we cannot use some Tmp table which we would pre-fill upon openning with converted values.

Is there any option how I can tell SQL to do the magic for me using Computed Columns or join some View which will convert all quantities to the UnitId I specify?
Or simply: Can I do the unit convertion using Computed column?

I have the same question (0)
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Volodymyr2127,

    For convertion  you can check UnitOfMeasureConverter_Product class.

    UnitOfMeasureConverter_Product unitConverter  = UnitOfMeasureConverter_Product::construct();
    unitConverter.parmProduct(InventTable::find("Test",true).Product);
    unitConverter.parmFromUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol("g"));
    unitConverter.parmToUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol("kg"));

    A computed column method  it returns a piece of T-SQL code for the calculation. The method is executed on database synchronization and the piece of T-SQL code is inserted to the view definition.

    If you want to use computed columns, your need to prepare SQL code that you want to generate.

    Obviously can't use X classes (such as UnitOfMeasureConverter) in SQL.

  • Martin Dráb Profile Picture
    239,471 Most Valuable Professional on at

    The logic for conversions is pretty complicated; rewriting it to T-SQL (and then writing X++ code generating this T-SQL code) wouldn't be a huge task. I don't think it's worth it.

    By the way, which version of AX are you talking about?

  • Community Member Profile Picture
    on at

    Dynamics 365 F&O 10.0.12

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 622

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 532 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans