Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

InventTrans reference to original purchase order

(0) ShareShare
ReportReport
Posted on by 282

Hi all,

Running AX2012 R3 CU10 and I'm having a bit of an issue.

Currently, I'm running a display method on a form which uses InventTransOrigin.ReferenceId to pull info on the original purchase order of a stock transaction. However, this isn't ideal because ReferenceId will change to the most recent stock transfer journal if we move stock around. I can't see another way of linking it to the purchase order.

I'm trying to think of the most frictionless way of solving my issue. Is there a way when the InventTrans or InventTransOrigin record is created, I can capture the RecId of the PurchLine record it originally referred to, or even the purchase order number? I can't see where ReferenceId is originally set in any init()-type functions on either of these tables. Alternately, is there somewhere else where this link is stored that I'm missing?

Thanks very much in advance,

Luke

*This post is locked for comments

  • lukbel Profile Picture
    282 on at
    RE: InventTrans reference to original purchase order

    Ahh, thank you very much! :D This has made my job a lot easier

  • Verified answer
    Community Member Profile Picture
    on at
    RE: InventTrans reference to original purchase order

    You are wrong, the relation is there:

    0317.pict1.png

  • lukbel Profile Picture
    282 on at
    RE: InventTrans reference to original purchase order

    Hi, InventTransId won't link to my purchase line which is where the information I need to display is - unless I am wrong? Is there a way to do this?

  • Community Member Profile Picture
    on at
    RE: InventTrans reference to original purchase order

    You cant keep the referenceId because this is changing everytime, And you cant update the table or get the purchId.

    you can use the inventTransId value to do the relation in your display.

    that the best way use the invetTransId.

  • lukbel Profile Picture
    282 on at
    RE: InventTrans reference to original purchase order

    Hi

    Ahh, I thought that maybe but I was sure transRefId referred to a field within InventTrans. Would I be able to manually set a value on the new inventTransOriginId object?

    If so, could I do this just through basic variable set InventTransOriginId.ReferenceId = ___ or would I need to do forUpdate SQL?

    Thanks very much

  • Community Member Profile Picture
    on at
    RE: InventTrans reference to original purchase order

    You can see here:

      if (!inventTransOriginId)

       {

           itemInventDim = movement.inventdim().data();

           itemInventDim.clearNotProductDim(movement.inventDimGroupSetup());

           inventTransOriginId = InventTransOrigin::create(

                                   movement.transId(),

                                   movement.itemId(),

                                   movement.transType(),

                                   movement.transRefId(),

                                   movement.dirParty(),

                                   InventDim::findOrCreate(itemInventDim).InventDimId).RecId;

           movement.inventTransOriginId(inventTransOriginId);

           movement.createOriginOwnerRelationship();

       }

    The movement.TransRefId is the number that are you looking for?

  • lukbel Profile Picture
    282 on at
    RE: InventTrans reference to original purchase order

    Hi,

    That seems along the right lines! However, I can't seem to see the code set ReferenceId, this would probably be where I would insert it?

    Pls advise, thanks

  • Community Member Profile Picture
    on at
    RE: InventTrans reference to original purchase order

    You can check the Class\InventUpdate\CreateInventTransOriginAndReferences.

    Tell me if that works for you, if not I can search more for you.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
Zain Mehmood Profile Picture

Zain Mehmood 6 Moderator

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans