web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Registering/Receiving Inventory with X++ - AX 2012

(0) ShareShare
ReportReport
Posted on by 4,074

We are trying to register some product (Site, Warehouse, Location, Serial Number) for a receiving service in AX 2012.  What is the proper way to do this? 

I have it working if the product doesn't require serial number, I just update the line's Receive Now quantity and PurchFormLetter.update using PurchUpdate::ReceiveNow quantity.

But for things that require a serial number, I have to register that product first, then use the PurchUpdate::Recorded quantity to receive in. 

Basically, I need to perform the function of the InventTransRegister Form in X++ code.  How is this accomplished?

Thanks

 

*This post is locked for comments

I have the same question (0)
  • dolee Profile Picture
    11,279 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Hi Andy,

    I haven't done this before myself, but after looking at the AOT, you can try investigate the InventTransWMS and InventTransWMS_Register class for starters.

  • Andy Adamak Profile Picture
    4,074 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    I've already been looking at that.  I can get the inventory dimensions in  (Site, Warehouse, Location, Serial Number), but the status is still "Ordered"... can't figure out how to get it registered.

    If you open a PO, click the Receive tab, click Product receipt, click the lines tab, click update line -> Registration, this is the process I'm talking about doing in code.  I can get everything set in the upper half of the grid, but I can't figure out how to then register it.  

  • dolee Profile Picture
    11,279 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Hi Andy,

    For some reason I can't post code here. Please check this post (domhk.blogspot.hk/.../ax2012-update-invent-registration-from.html) for an example that you can try in your development or testing environment.

  • Andy Adamak Profile Picture
    4,074 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Thanks dolee!

    This seems to be working better than what I had.  My only issue is, and I'm not sure if it's something to do with the code or something's messed up in the system, that some (16 out of 115) records throw an error saying:

    "Posting  Purchase order: PO-000001  Item: TestItem  Transaction has already been posted physically.  Posting An error occurred during update"

    I never got this one while doing things my old way.  Any ideas into this error?  

    Thanks,

  • dolee Profile Picture
    11,279 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Nope, haven't seen any error when I wrote the job.

    Any hints from the debugger?

  • Andy Adamak Profile Picture
    4,074 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Nope.  I'm 80% sure it's something messed up with 2 of my orders though.  Otherwise, your solution works great!  Thanks for the help!

  • Andy Adamak Profile Picture
    4,074 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    So I turned out to be wrong.. the code you provided has one flaw:  

    InventTrans             inventTrans = InventTrans::findTransId();

    This bit of code simply grabs the first InventTransOrigin record where the InventTransID's match, then grabs the FIRST record of the InventTrans table where it matches up with the origin... regardless of status. The issue I was running into was even if it was received/registered, whatever status, it would grab the first InventTrans and override the record and it's InventDim record as well.

    So... It works, but not really because it totally messes up all your transactions if you receive more than once against the same PO line.

  • dolee Profile Picture
    11,279 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Thanks for the update, really appreciate it. I will update my post with your findings.

    I hope things turn out ok for you once this flaw is taken care of. :)

  • Andy Adamak Profile Picture
    4,074 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    So I think I got it.  InventTrans::findTransId() wasn't cutting it for the above explained reason.  So, I used a similar query from that method, but made an addition to the where clause to grab inventTrans.StatusReceipt == StatusReceipt::Ordered.

    Also, instead of setting the inventDim = inventTrans.inventDim(), I created a brand new InventDim to set all my registration variables (SerialNumber, Location, Warehouse, etc etc)  This seems to help prevent the occasional overriding of serial numbers (Invent Dims). 

    The entire code is quite lengthy, but these two things fixed the major issues I was having. 

  • Andy Adamak Profile Picture
    4,074 on at
    Re: Registering/Receiving Inventory with X++ - AX 2012

    Now the question is how to unregister if receiving the line fails? New post here:

    community.dynamics.com/.../101762.aspx

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans