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 :
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

I have the same question (0)
  • Community Member Profile Picture
    on at

    You can check the Class\InventUpdate\CreateInventTransOriginAndReferences.

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

  • lukbel Profile Picture
    282 on at

    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

    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

    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

    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

    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?

  • Verified answer
    Community Member Profile Picture
    on at

    You are wrong, the relation is there:

    0317.pict1.png

  • lukbel Profile Picture
    282 on at

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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans