Customizing SSRS Report Using Extension in D365FO - Locus IT Services

Customizing SSRS Report Using Extension in D365FO

Locus IT ServicesNewsCustomizing SSRS Report Using Extension in D365FO

Customizing SSRS Report Using Extension in D365FO

In this article, Customizing SSRS Report Using Extension in D365FO is explained that is how to customize and extend data set and design of Free Text Invoice report.

Two fields need to be added in the table and to show these fields in Free Text Invoice report. If you have come across the Free Text Invoice report, you may have noticed that it uses contract class, controller class, DP class and print management class to generate the report.

To customize SSRS report using extension in Microsoft Dynamics 365 F&O is to create the extension of table, implement the events to insert the data into the extended fields, customize the design, extend the controller class and subscribe to the delegate of print management document type class to re-route the print management to execute your new design.

Customizing SSRS Report Using Extension in D365FO Steps

  • Create extension of FreeTextInvoiceTmp table and add the field i.e. TotalAmounInWords
  • Create a class named FreeTextInvoiceController_Events to implement the event handler methods
  • Copy the post handler event method of processReport() of FreeTextInvoiceDP class and paste in the class created in previous step.
    • NOTE: You can also use the OnInserting event of table instead of processReport() of DP class.
  • Write the following logic to insert the data into the TotalAmounInWords field we have created:
class FreeTextInvoiceController_Events
    [PostHandlerFor(classStr(FreeTextInvoiceDP), methodStr(FreeTextInvoiceDP, processReport))]
    public static void FreeTextInvoiceDP_Post_processReport(XppPrePostArgs args)
        FreeTextInvoiceDP dpInstance = args.getThis() as FreeTextInvoiceDP;
        FreeTextInvoiceHeaderFooterTmp freeTextInvoiceHeaderFooterTmp = dpInstance.getFreeTextInvoiceHeaderFooterTmp();
        FreeTextInvoiceTmp freeTextInvoiceTmp = dpInstance.getFreeTextInvoiceTmp();
        while select forUpdate freeTextInvoiceTmp
            freeTextInvoiceTmp.TotalAmounInWords = numeralsToTxt(freeTextInvoiceTmp.InvoiceAmount);
  • Find out the FreeTextInvoice report in the AOT
    • Right-click the report and click Duplicate in project.
    • Customize the design and add TotalAmountInWords field as per your requirements
    • Create another class named FreeTextInvoiceControllerExt which extends the FreeTextInvoiceController class. Override the main() method. Give the new report and it’s design name in it.
    • Add the following logic in FreeTextInvoiceControllerExt class:
class FreeTextInvoiceControllerExt extends FreeTextInvoiceController
    public static FreeTextInvoiceControllerExt construct()
        return new FreeTextInvoiceControllerExt();

    public static void main(Args _args)
        SrsReportRunController formLetterController = FreeTextInvoiceControllerExt::construct();
        FreeTextInvoiceControllerExt controller = formLetterController;
        controller.parmReportName(ssrsReportStr(FreeTextInvoiceCopy, Report));
  • Create another class named PrintMgtDocTypeHandlersExt
  • Add a method in it which subscribes to the event delegate of PrintMgmtDocType class to re-route the report from the default to this customized report
  • Add the following logic in PrintMgtDocTypeHandlersExt class:
class PrintMgtDocTypeHandlersExt
    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
        switch (_docType)
            case PrintMgmtDocumentType::SalesFreeTextInvoice:
                _result.result(ssrsReportStr(FreeTextInvoiceCopy, Report));
  • Create extension of the following menu items which executes report:
          • FreeTextInvoiceCopy
          • FreeTextInvoiceOriginal
  • Change the controller class name in the Object property of the extended menu items to the FreeTextInvoiceControllerExt class created above
  • Save, build and synchronize and deploy the project/reports.

Dynamics 365 for Finance and Operations is an Enterprise Resource Planning (ERP) suite. It provides the deployment options that gives you the flexibility to start on one scenario and change later.

From full cloud to cloud + edge to local business data, you can move in either direction based on your organisations business needs. For more information on Customizing SSRS Report Using Extension in D365FO, please contact us.

Locus IT Project Management Office
What’s it?