Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Run method after Generating Sales Invoice

Posted on by Microsoft Employee

Sales order Lines > Invoice > Generate (Invoice) > PrintMgnmt > OK

i need to run a method after Generating Sales Invoice

I tried putting the code in the last part or closeOK and closedOK (i tried info("aa"); first)

but when i tried it, it will prompt before the Confirmation Warning ("Warning: You are posting the invoice and printing to screen only.").

how can i put it after the Warning and everything is OK and POSTED.

please help. thanks.

*This post is locked for comments

  • Verified answer
    Brandon Wiese Profile Picture
    Brandon Wiese 17,786 on at
    RE: Run method after Generating Sales Invoice

    I've also had forms that need to appear after some form letter document is posted, such as the Sales invoice.

    Try launching your form in the SalesFormLetter_Invoice class in the run() method after the super() call.  Make sure NOT to launch your form when it's not appropriate.  For example, if the Sales invoice is proforma, then there will be no records left, so probably not useful to launch your form.  If the thread is a CLR session, then you won't be able to run client code at all and it will error if you try.

    Here's a sample of code that I've actually used for this purpose.  In my case I only wanted the form to appear if the form letter document wasn't printed, hence the !this.printFormLetter() check.

    super();

    if (!this.salesParmUpdate().Proforma && !this.printFormLetter() && this.parmShowDialog()) { if (xGlobal::hasClient() && !xSession::isCLRSession()) { // launch your form here } }
  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Run method after Generating Sales Invoice

    a good approach can be to follow the path of sales invoice report, i.e. as you are going to post an invoice there is checkbox, if you check it,, it prints sales invoice report, else it ignores it. in case you marked this checkbox of printing invoice, it is printed only in case, invoice has no issues and everything is fine. i.e after posting the invoice the printout appears.

    so do follow the same logic and let your custom form appear somewhere before or after that report because till that moment,, invoice is already posted (either in case of Performa or actual posting)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Run method after Generating Sales Invoice

    Hi martin,

    im supposed to run a custom form that su,mmarizes and splits the sales invoice by 15 lines each, and giving them each a preprinted si number for printing. I msnaged to make it and it is working now (tested it All in custom tables/forms to run).

    But now i need to deploy it in the SI posting now, which is the problem, i need posted SI before running the custom form.

    How can i run it after posting SI(after all the warnings yes/no)

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    RE: Run method after Generating Sales Invoice

    Posting is done in SalesInvoiceJournalPost class. You can find it by yourself next time in Using the Refactored Formletter Framework.

    I can't say what would be the place for your business logic because you didn't tell us anything about it.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans