Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Codeunit::"Purch.-Get Receipt" CreateInvLines() procedure oddness

(0) ShareShare
ReportReport
Posted on by 385
I forwarded these details over to our Microsoft partner, so that hopefully a ticket is opened with Microsoft. Just wanted to post the details here in case someone might have some insight. 
 
We are presently using BC 365 SaaS v23.1. We have a routine that allows the user to select Posted Purchase Receipt lines and push them into a new Purchase Invoice. That /push/ just uses the base Microsoft Codeunit::/Purch.-Get Receipt/ CreateInvLines() procedure. This all passed UAT back last summer, but now when testing again we notice an apparent bug.
 
Say we have a Posted Purchase Receipt line that has a Global Dimension Code 1 value assigned as 'NASH.' Debugging the routine, we can see this value in the Posted Purchase Receipt line being fed into the CreateInvLines() procedure. But when the Purchase Invoice line is subsequently created, the Global Dimension Code 1 value for the line appears to revert to what's defined in the Purchase Invoice header. In this case that would be 'DCH,' which is unexpected and breaks the logic one would expect.
 
I will attach some screen shots below. Can anyone feedback as to experiences like this?
 
 //
 
//
 
//
 
//
  • Verified answer
    Greg Kujawa Profile Picture
    385 on at
    Codeunit::"Purch.-Get Receipt" CreateInvLines() procedure oddness
    Thanks so much for the hint. It would be cleaner handling the event trigger behind the scenes. As opposed to having the user manually click an action button to achieve the same thing. 

    I gave this a shot, and attached subscribers to both the OnAfterInsertInvoiceLineFromReceiptLine() and OnAfterCreateInvLines() events. Debugging I can see that the purchase line's Shortcut Dimension 1 Code is being properly derived, and I'm saving away the modified purchase line. But when I pull up the purchase invoice afterward I still see the incorrect Shortcut Dimension 1 Code being listed in the lines.

    What's interesting is if I use the base Microsoft action of clicking Get Receipt Lines from the Purchase Invoice line, then those ported-in purchase receipt lines do properly maintain their Shortcut Dimension 1 Code. And as far as I can tell both my custom code and this base Microsoft action are using the same base Microsoft CreateInvLines() procedure.

    UPDATE: I was able to determine what was going on. After the purchase invoice was created in my custom code the lines were correctly identifying things. But the routine then opens up the new document. And validates a few key fields before opening. Validating the Location Code field was causing the Shortcut Dimension 1 Code to revert for some odd reason. I fixed that and all is well! 
  • Suggested answer
    YUN ZHU Profile Picture
    84,278 Super User 2025 Season 1 on at
    Codeunit::"Purch.-Get Receipt" CreateInvLines() procedure oddness
    Hi, if this is a standard environment, you can try submitting an SR to Microsoft Support. Let them assist in the investigation.
    However, in addition to manual updates, I think you can consider subscribing to these two events to see if it can solve your needs.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • Greg Kujawa Profile Picture
    385 on at
    Codeunit::"Purch.-Get Receipt" CreateInvLines() procedure oddness
    For now I just added a custom action to the Purchase Invoice subform. This action iterates through the Purchase Invoice lines, looks up the Global Dimension Code 1 value associated with the Location Code in the Default Dimension table, and updates that value in the Purchase Invoice line. A workaround at least, since we could have a couple hundred line items to otherwise manually correct due to this apparent bug.
     
    Here's a vid cap of the particulars, if anyone is interested. Vid Cap 

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

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

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans