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

Order By in MorphX report doesn't work properly in X++ code

(0) ShareShare
ReportReport
Posted on by 157

Hello Everyone

I wrote the code below....
In the first case I try to sort the lines of the report by itemId and ItemRoutId and it works fine 

while select ProdBOMtmp order by ItemRouteId,ItemId
    where ProdBOMtmp.OprNum == ProdRoute.OprNum
    outer join prodJournalBOMselect
        where prodJournalBOMselect.InventTransId == ProdBOMtmp.InventTransId
        && prodJournalBOMselect.JournalId == prodJournalBOM.JournalId
        outer join MyInventItemLocation 
            where MyInventItemLocation.InventItemLocation == prodJournalBOMselect.InventItemLocation



In the second case I try to sort the lines by printingSequence witch is in a custom MyInventItemLocation table
(I already use this field in other reports and the order works fine)


while select ProdBOMtmp 
    where ProdBOMtmp.OprNum == ProdRoute.OprNum
    outer join prodJournalBOMselect
        where prodJournalBOMselect.InventTransId == ProdBOMtmp.InventTransId
        && prodJournalBOMselect.JournalId == prodJournalBOM.JournalId
        outer join MyInventItemLocation order by printingSequence
            where MyInventItemLocation.InventItemLocation == prodJournalBOMselect.InventItemLocation


But in this one doesn't work. 

Does anyone understand why?????

I have the same question (0)
  • nmaenpaa Profile Picture
    101,172 Moderator on at

    You say that you use it in some other place and it works fine. Perhaps you can compare your x++ select statements that work, to spot the difference to the one that doesn't work as you would expect.

    These queries and the sort order of the result is not related to MorphX reports, so you can just test it in a job.

    The report simply displays the data that you provide to it, in the order that you provide in the select statement.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi SGbon,

    Please try this -

    while select ProdBOMtmp 
        order by MyInventItemLocation.printingSequence
        where ProdBOMtmp.OprNum == ProdRoute.OprNum
        outer join prodJournalBOMselect
            where prodJournalBOMselect.InventTransId == ProdBOMtmp.InventTransId
            && prodJournalBOMselect.JournalId == prodJournalBOM.JournalId
            outer join MyInventItemLocation 
                where MyInventItemLocation.InventItemLocation == prodJournalBOMselect.InventItemLocation

  • SGbron Profile Picture
    157 on at

    So I found where the problem was.

    Somewhere in the code the ProdBOMtmp has  the property ProdBOMtmp.setTmp().

    That turns the table to temporary Table.

    So the join statements was not working becasue of that.

  • MuthukumaranAX Profile Picture
    2,903 on at

    Hi SGbron,

    Could you pls mark it as "Resolved, if the issue is fixed.

    thanks

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 March 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 694

#2
André Arnaud de Calavon Profile Picture

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

#3
CP04-islander Profile Picture

CP04-islander 337

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans