Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

how to reference the same field in a self join from a AOT query in a data provider

Posted on by 70

Hello,

Quick question:

How do I reference a field in a self join? I have a AOT query which I am building a data provider for. 

The query is as follows:

pastedimage1568299773043v1.png

Now I have a self join on Ecorescategory to get the category and parent category which is in the field 'Name'.

My DP uses RecordInsertList however in the query run I do not know how to reference it and the name I have given it in the query does not work for the table.

        ItemVariantView  ItemVariantView = _queryRun.get(tableNum(ItemVariantView));
        ProductPricingReportTempTable.ItemId = ItemVariantView.ItemId;
        ProductPricingReportTempTable.VariantId = ItemVariantView.VariantId;

        PriceDiscTable  priceDiscTable = _queryRun.get(tableNum(PriceDiscTable));
        ProductPricingReportTempTable.AccountRelation  = priceDiscTable.AccountRelation;
        ProductPricingReportTempTable.Amount = priceDiscTable.Amount;
        ProductPricingReportTempTable.Currency = priceDiscTable.Currency;
        ProductPricingReportTempTable.FromDate = priceDiscTable.FromDate;
        ProductPricingReportTempTable.ReasonCode = priceDiscTable.ReasonCode;
        ProductPricingReportTempTable.ToDate = priceDiscTable.ToDate;


        EcoResCategory ecoResCategory = _queryRun.get(tableNum(EcoResCategory));
        ProductPricingReportTempTable.Category = ecoResCategory.Name;

Hope that makes sense?

*This post is locked for comments

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: how to reference the same field in a self join from a AOT query in a data provider

    Another option is utilizing the second parameter of get: _queryRun.get(tableNum(EcoResCategory), 2).

  • Verified answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: how to reference the same field in a self join from a AOT query in a data provider

    Hi!

    You can try to use _queryRun.getNo() instead of get().

    docs.microsoft.com/.../how-to-create-queries-by-using-x

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans