web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to Add a Toggle in "Posting Invoice" to Trigger Custom SSRS Report Printing After Posting?

(3) ShareShare
ReportReport
Posted on by 317



Hi everyone,

 

I need to add a new toggle in the Posting Invoice form under AR > Invoices > Batch invoicing > Invoice. The purpose of this toggle is to trigger the printing of a custom SSRS report automatically after the invoice is posted successfully.

Details:


  1. How can I add a new toggle to the Posting Invoice form using an extension or other method?

  2. Once the toggle is selected and the invoice is posted, how can I trigger the printing of my custom SSRS report automatically?

  3. What event handler or controller should I use to invoke the print process after the posting is done?


  4.  

Thanks in advance for your help!

I have the same question (3)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,801 Super User 2026 Season 1 on at
     
    I think you need extend the following elements to add the toggle : 
    SalesFormLetter_Invoice class
    * SalesParmUpdate table
    * SalesEditLines form
     
    BR
  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    You don't have to design it on your own from scratch - you can look at how Print COD or Print shipping labels is handled in the standard application. You'll find that the class for invoice printing is called SalesInvoiceJournalPrint and the method triggering the print of Print COD and Print shipping labels is printJournal().
  • Statics 365 Profile Picture
    317 on at

    Thanks for the suggestions. Quick update on what I tried and where I’m stuck:


    •  Goal: Add a new toggle on the Posting invoice dialog (Sales order invoice posting / SalesEditLines) so that after a successful post, the system automatically opens/preview (Screen) my custom SSRS report. I have multiple custom reports and want each one independent (separate toggles), not tied to Print management changes and not mixed with standard Print invoice/COD/shipping toggles.

    What I tried


    1.  Hook after posting on SalesFormLetter_Invoice.afterOperationBody()
       

      •  Confirmed method is hit (I can log).

      •  I can read ParmId and confirm my toggle value = Yes (stored in SalesParmUpdate using ParmId).

      •  But calling SrsReportRunController with Screen/preview from there fails with:


        “Cannot run form on non interactive session.”

        So this point seems server/non-interactive 


    2.  Queue approach (server → client)
       

      •  In afterOperationBody() I insert into a custom queue table: {UserId, DataAreaId, ParmId, CreatedDateTime}.

      •  Then I tried a client-side handler on the posting dialog:
         

        •  SalesEditLines form event (Closing) reads queue record for current user/company, finds CustInvoiceJour by ParmId, then calls SrsReportRunController with SRSPrintMediumType::Screen.     

      •  Result: nothing happens after posting (no error, no preview). It looks like the form event is either not firing reliably for this scenario or it fires before the queue/journal is selectable   

    Questions


    •  What is the recommended pattern to trigger an interactive report preview right after a successful invoice posting?

    •  Which client-side point is best to hook (form event, controller, menu item wrapper, post-run method, etc.) so it runs in an interactive session?

    •  If you’ve implemented something similar (custom toggle → print custom SSRS post-success), could you share sample code, or at least which class/form/event you hooked?
  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    Cannot run form on non interactive session means that the execute in an asynchronous way and it doesn't have any client to open the report viewer form. Either you'll use a better place for your code, or you'll check for this situation and skip the report. I guess you don't want the latter.
     
    I already gave you my suggestion - the class dealing with the reports is SalesInvoiceJournalPrint.
  • Statics 365 Profile Picture
    317 on at

    Thanks @Martin Dráb, that explains the “non-interactive session” error clearly.

     

    I’ll focus on SalesInvoiceJournalPrint as you suggested. Could you please confirm which method/hook point you recommend there? For example, should I extend SalesInvoiceJournalPrint.printJournal(Set _journalList) after super() to trigger my custom SSRS report?

     

    Also, my goal is interactive Screen preview right after posting (not batch). In your experience, is it safe to open SSRS viewer from that printing pipeline, or should I always trigger it from a client-side form/controller instead (and only print to printer/file in batch)?

     

    If you have a small code snippet or the standard pattern (similar to COD label/shipping label printing), I’d really appreciate it.

  • Verified answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    As I said in the first reply, printJournal() is the method where Microsoft call the report. You should do the same, unless you have a specific reason to divert from the custom solution. You also asked for an example - simply open the method to see it. Printing of COD and shipping labels is handled by printJournal() in SalesInvoiceJournalPrint class, while the invoice report itself is in the parent class (FormletterJournalPrint.printJournal()).
     
    My experience is that the standard invoice printing do support printing on screen (when it's not in batch, of course). You can try the standard report(s) to see it for yourself.
  • Statics 365 Profile Picture
    317 on at
    Hi @Martin Dráb, just an update — I managed to get it working now. Your suggestion to focus on SalesInvoiceJournalPrint.printJournal() was the right direction. Thanks a lot for your help and guidance!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans