Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

(0) ShareShare
ReportReport
Posted on by 170

Hello! I have a problem with posting additional General Journal Line right after post Vendor Ledger Entry.

What am I doing and what I want to achieve?

In CU90 there is a function PostGLAndVendor and in it the PostVendEntry, which creates GenJnlLine and post it. I need to create additional GenJnlLine and post it too, but if my additional posting will end with error, all changes should roll back. The issue is that when the second posting ends with error, the Posted Purchase Invoice is still permanently posted in system with all G/L Lines etc.

My second idea was that. I will create function in codeunit 90 right after MakeInventoryAdjustment, before UpdateLastPostingNos functions. And strange things are happening now. My function only create TWO General Ledger Entries and post it. For debbuging I gave an ERROR('Rollback') instead my function and it was OK! After ERROR all changes was rolled back. But if my function is handled, on VALIDATE Account No. field there is a code, which is checking if Vendor f.ex. is blocked. After this validation and system error my posted invoice is still posted.  I don't know why!

Could you tell me, when the posting transaction starts and where ends? And how can I achieve the posting of additional general journal lines in ONE transaction?

Greetings!

*This post is locked for comments

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    Instead of validating fields in your second function, just assign the values and try. If any error occurs it should rollback everything.

  • MateuszKILINSKI Profile Picture
    MateuszKILINSKI 170 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    The same function as orginal...

    PostVendorEntry Function: https://i.imgur.com/GIpDAad.jpg
    TryPostSecondGJLine Function: https://i.imgur.com/HHmFr2t.jpg

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    Please share your code, what functions you are calling for posting?

  • MateuszKILINSKI Profile Picture
    MateuszKILINSKI 170 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    No, because I don't want to end the transaction.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    Did you add any commit in your code? can you share your code

  • MateuszKILINSKI Profile Picture
    MateuszKILINSKI 170 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    I want to post my line AFTER post orginal Vendor Entry. I've created my code right after GenJnlPostLine.RunWithCheck(GenJnlLine) in PostVendorEntry function in Codeunit 90.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Post additional GenJnlLine after posting Vendor Ledger Entry on Purchase Invoice

    Where did you add the code to create additional G/L Line? Do you want to post this line before or after the Vendor Entry?

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans