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 :
Finance | Project Operations, Human Resources, ...
Answered

SalesFormLetter_invoice post action

(0) ShareShare
ReportReport
Posted on by 55

Hello Dynamics Community,

I need to run some code after posting a sales order invoice. I tried creating various post event handlers as well as a chain of command approach, but for some reason, my code is never executed. It appears that since this is executed as a service things are different. Can anyone elaborate ? What is the right way to run code after let's say salesFormLetter_Invoice.update() ?

Sincerely

Darrell

I have the same question (0)
  • Martin Dráb Profile Picture
    235,800 Most Valuable Professional on at
    RE: SalesFormLetter_invoice post action

    LedgerJournalCheckPost is used in batch posting as well. What exact problem do you have with debugging?

    Can you show us your code, please? Did you see the verified answer above which uses Chain of command?

  • Swetha K Desai Profile Picture
    50 on at
    RE: SalesFormLetter_invoice post action

    Hello Martin,

    The wrote the code in the custom code in SalesInvoiceJournalPost.endPost() , although manual posting behaviour did not change, the batch posting still does not post amortizations.

    Will check more on the batch posting in LedgerJournalCheckPost class and update if any progress

    Thanks,

    Swetha K Desai

  • Swetha K Desai Profile Picture
    50 on at
    RE: SalesFormLetter_invoice post action

    Hello Martin,

    I have a post event handler method written on the SalesFormLetter_Invoice - run method. In this post event handler, there is custom code to post the amortizations (revenue recognition entries) on the invoice.

    When I post an invoice manually, the post event handler does get fired and the amortizations do get posted. However, when this is done through a batch job, the amortizations are NOT posted as the post event handler does not seem to execute.

    When I try to debug this in batch mode, I am unable to hit the breakpoint and the batch job finishes with invoice posting correctly with no amortizations posted. I understand that this behaviour might be because the batch job is multithreaded.

    Can you please suggest where the code can be rewritten so this can be executed in batch mode as well. Does SalesInvoiceJournalPost.endPost() still would help? Also, any pointers you can give me to help debug multithreaded batch jobs?

    Thanks,

    Swetha K Desai

  • Darrell Crews Profile Picture
    55 on at
    RE: SalesFormLetter_invoice post action

    Thank you

  • Darrell Crews Profile Picture
    55 on at
    RE: SalesFormLetter_invoice post action

    Thank you

  • Suggested answer
    Frank Bruemmer Profile Picture
    354 on at
    RE: SalesFormLetter_invoice post action

    Hey Darrell,

    as Martin suggested, this approach will work :

    [ExtensionOf(ClassStr(SalesInvoiceJournalPost))]

    final class SalesInvoiceJournalPost_Extension

    {

       protected void endPost()

       {

           next endPost();

           Info(strFmt("SalesId : %1",custInvoicejour.salesId));

       }

    }

    I don't think you will be able to use pre/post event handlers as endPost() is not a public method (protected).

    Best regards

    Frank

  • Verified answer
    Martin Dráb Profile Picture
    235,800 Most Valuable Professional on at
    RE: SalesFormLetter_invoice post action

    SalesInvoiceJournalPost.endPost() sounds like the right place for what you asked for.

  • André Arnaud de Calavon Profile Picture
    297,205 Super User 2025 Season 2 on at
    RE: SalesFormLetter_invoice post action

    Hi Darell,

    Usually CoC would be an option, but you made this attempt already. Can you share your code and tell what exact business requirement you try to fulfill?

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 665 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 595 Most Valuable Professional

#3
Yng Lih Profile Picture

Yng Lih 558

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans