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 :
Microsoft Dynamics AX (Archived)

Run method after Generating Sales Invoice

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    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.

  • Community Member Profile Picture
    on at

    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)

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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)

  • Verified answer
    Brandon Wiese Profile Picture
    17,788 on at

    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 } }

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans