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

Notifications

Announcements

No record found.

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 583
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?
 
 //
 
//
 
//
 
//
I have the same question (0)
  • Greg Kujawa Profile Picture
    583 on at
    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 
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    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
  • Verified answer
    Greg Kujawa Profile Picture
    583 on at
    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! 

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans