Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Relation of InventTrans and InventTransOrigin in a select statement

Posted on by 270

I am using this select statement:

select * from inventTrans where inventTrans.InventTransOrigin == inventTransOrigin.RecId

however it doesn't return anything, where in fact the relation of InventTrans and InventTransOrigin is that.

I looked at the table inventTrans (via table browser) and saw that the inventTrans.InventTransOrigin is a TransId. So I did this:

select * from inventTrans where inventTrans.InventTransOrigin == str2Int64(inventTransOrigin.InventTransId)

however it still doesn't return anything.

What am I missing?

*This post is locked for comments

  • Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Relation of InventTrans and InventTransOrigin in a select statement

    No problem, kindly mark helpful answers next to each post to resolve the thread.

  • Miguel Zuniga Profile Picture
    Miguel Zuniga 270 on at
    RE: Relation of InventTrans and InventTransOrigin in a select statement

    Hi Vilmos,

    My apologies. Just had an error in my select statements.  But I've understood that inventTrans.InventTransOrigin returns a RecId, not an InventTransId.

    Thanks!

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Relation of InventTrans and InventTransOrigin in a select statement

    It is possibly a replacement key, so on regular UI it could be showing the replacement value (InventTransId). Check the data in SQL directly, I would be expecting RecId values (for which you would need to write the RecId reference in the statement).

  • Miguel Zuniga Profile Picture
    Miguel Zuniga 270 on at
    RE: Relation of InventTrans and InventTransOrigin in a select statement

    Hi Vilmos,

    I tried the second statement because the column InventTransOrigin in the table itself InventTrans is displayed as the InventTransId.  So when I equate that to the InventTransOrigin.InventTransId, the compiler said:

    "Operator '==' cannot be applied to operands of type 'int64' to 'str'." So I did conversion.

    Their relation is indeed InventTrans.InventTransOrigin == InventTransOrigin.RecId, however it can't return something because the table is displaying the InventTransOrigin as an InventTransId.

    InventTrans.InventTransOrigin.PNG

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Relation of InventTrans and InventTransOrigin in a select statement

    How did you come to the conclusion about the relation for your second statement, and why are you trying to do a value conversion?

    The first syntax looks correct to me as per the relations (though screenshot is from AX 2012):

    inventtransrel.png

    If you do not get back anything, that means you are possibly in the wrong company which has no transactions, or you do not have data in your environment at all.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans