Wednesday 8 July 2020

Extend Sales Invoice report

Step 1) Create a new project.

Step 2) Assume that I want to add AdditionalQty field on body of report so I am going to create a extension of SalesInvoiceTmp table and add required fields within it.







Step 3) Build and Synchronize the table.

Step 4) Create a new helper class in my case I have created SalesInvoiceHelper class and copy onInserting event handler of SalesInvoice tmp table. Add logic within the copied event handler.













Note : For the demo purpose I have added logic for this  field. Whereas as  you can add logic as per your requirements.













Step 4) Duplicate the report  and give it a new name. Make changes in design accordingly.



















Step 5)  Go to PrintMgmtDocType class and copy event handler of getDefaultReportFormatDelegate and subscribe to its event handler. Add logic in the method to call this new report in helper class.


























Step 6) Duplicate Sales invoice controller class  by creating new controller and change its logic in order to call your new report.

For instance in my class I have replaced SalesInvoicecontroller instance with salesInvoiceControllerDemo and called my report SalesinvoiceDemo with design Report.


















Step 7)  Extend sales invoice report menu item and change its controller property to your new controller.


Before creating new extension of menu item.











After creating new extension.












Build the complete project and execute your report.

Here comes the error.










Oops. Probably I missed something and that is deploying my report. Right click on your project and select deploy reports.

One more thing go to Account receivable ->Setup -> Form setup -> Select print management
Go to customer invoice node and select your design and report there too.














Final output with our custom column.













http://dynamicsaxtechnicalstuff.blogspot.com/2019/01/customize-design-and-business-logic-of.html