Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / VendEditInvoice PostIn...
Finance forum

VendEditInvoice PostInvoice fails after Post Event Handler

(0) ShareShare
ReportReport
Posted on by 105

It is my understanding that the post event handler will work in case you what to do something after the event, right? I have implemented other post event handlers in the past and if the event fails it did no hit the post event handler, which is what I would expect, except that in the VendEditInvoice Post postInvoice Event Handler it does not happen this way.

I want to update the status of a record in my table only if the invoice is posted, so I program this in the Post postInvoice Event Handler. As I debug, I discover that the post event handler is hit and then the invoice fails to post!

Is this really the expected behavior? If so, witch event should I use to update my record status?

Thanks in advance.

  • André Arnaud de Calavon Profile Picture
    294,283 Super User 2025 Season 1 on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    Hi Emilio,

    Did you extend the correct method here? Probably the error is raised in another method which you didn't extend?

  • Emilio Molina Profile Picture
    105 on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    Nikolaos,

    Thanks for you post. The problem is, as I try to explain in my first post, that the event handler is executed even if an exceptions happened in the standard method. My problem is that the exception happens after the event handler has been hit!

  • Suggested answer
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    The event handler will be executed if no exceptions happened in the standard method. The standard method might show some errors but still not throw an exception. And in that case your event handler code will be executed.

    So you need to add some logic in your event handler to find out if the invoice was really posted or not.

  • Emilio Molina Profile Picture
    105 on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    Hi Sukrut.

    I do not understand what do you mean with "Can you please provide information about where you wrote this event handler". I copy the event handler and paste it i a class.

    as for the SalesInvoiceJournalPost is for CustomerInvoice and the VendEditInvoice is for VendorInvoice

    Thanks for your help

  • Emilio Molina Profile Picture
    105 on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    Thanks for you post André.

    The thing is that when the post event handler gets hit I register the Invoice as successfully posted, and then by other circumstances a for example a bad financial dimension combination the invoice fails to post, but I am not aware of it because the post event handler has already been hit.

    Did this clarify in some way?

    Thanks in advance for your time!

  • Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    Hi Emilio ,

    From what you said it looks like your event handler is getting called before invoice posting status. Is that the case ? Can you please provide information about where you wrote this event handler ? Instead you should look at class SalesInvoiceJournalPost

  • André Arnaud de Calavon Profile Picture
    294,283 Super User 2025 Season 1 on at
    RE: VendEditInvoice PostInvoice fails after Post Event Handler

    Hi Emilio,

    Can you provide some details on what exactly you have done here? What do you mean with: "As I debug, I discover that the post event handler is hit and then the invoice fails to post!"? Is the posting of the invoice completed and in your post event there is an action that it actually still fails?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,283 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans