Friday, February 5, 2021

Customizing standard report in Dynamics 365 finance and operations

In this article we will introduce how to customize payment advice report. The example will be base on Vendor payment advice. If need apply on Customer payment advice, just need change vend to cust and check same.

1.      Related Objects

Report: BankPaymAdviceVend

Class: BankPaymAdviceVendController, BankPaymAdviceVendPrint, PrintMgtDocTypeHandlerExt

Output MenuItem: BankPaymAdviceVend

2.      Create model

Go to Dynamics 365àModel Management àCreate model


3. Click Next

4. Click Next, Select ApplicationFoundation and ApplicationSuite

5. Create Next and Create new project



6.      From AOT, find Report BankPaymAdviceVend

If you want how to find it is this report. You can find the Payment advice button from payment journal and it’s menu item BankPaymAdviceVendPrint, then you can find it calls class BankPaymAdviceVendPrint, and this class call menu item BankPaymAdviceVend



7. Then menu item calls controller BankPaymAdviceVendController, this controller call report BankPaymAdviceVend.



8. Duplicate the report and rename to BankPaymAdviceVendExt



9. Then Open BankPaymAdviceVendExt and apply the customizations you want.



10. For example:



11.      Deploy report

Right click the project and Rebuild, if no any errors, then Right click the project and Deploy reports



12.      Create a new class that extends the standard controller-- BankPaymAdviceVendController.

Right click ProjectàAddàNew Item…àClass, name BankPaymAdviceVendControllerExt



13. Override main method to specify the controller and report (Copy from BankPaymAdviceVendController and change).

class BankPaymAdviceVendControllerExt extends BankPaymAdviceVendController

{

    public static void main(Args _args)

    {

        SrsReportRunController controller = new BankPaymAdviceVendControllerExt();

        controller.parmReportName(ssrsReportStr(BankPaymAdviceVendExt, Report));

        controller.parmArgs(_args);

        controller.parmShowDialog(false);

        controller.startOperation();

    }

 

}

14.      Add customized report into default payment advice report list in print management.

Add a new class to the project. Name as PrintMgtDocTypeHandlerExt to distinguish it from other object handlers.

Add a delegate handler method to start to use custom report. In this example, extend the getDefaultReportFormatDelegate method in the PrintMgtDocTypeHandlerExt class by using the following code.

class PrintMgtDocTypeHandlerExt

{

    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]

    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)

    {

        switch (_docType)

        {

            case PrintMgmtDocumentType::VendPaymAdvice:

                _result.result(ssrsReportStr(BankPaymAdviceVendExt, Report));

                break;

        }

    }

 

}

15.      Create a extension of output menu item BankPaymAdviceVend


16. Right click and Open it, then change Object property to BankPaymAdviceVendControllerExt


17.      Change print management settings

Go to Accounts payableàFormsàForm setup, on General tab, click Print management

Find payment advice and right clickàNew, select the report you created.


18.      Find a vendor payment journal and try



 Hope this helps !, I will come-up with another interesting topic!

Extension class for SrsReportDataContract used to run custom design of reports instead of standard in Dynamics 365 finance and operations

In implementation projects its very common requirement to have generate custom report in place of standard reports, hence we need to duplicate the report design and extend controller class to print custom report. its one way of doing it . but there other way we can do by extending SrsReportDataContract class /parmReportName method. 

Please find below example for your reference.

/// <summary>
/// Extension class for SrsReportDataContract. used to run custom design of reports instead of standard.
/// </summary>
[ExtensionOf(classStr(SrsReportDataContract))]
final class JPSrsReportDataContract_JP_Extension
{
    public SRSCatalogItemName parmReportName(SRSCatalogItemName _reportName)
    {
        SRSCatalogItemName reportName;

        reportName = next parmReportName(_reportName);

        if(reportName == (ssrsReportStr(InventSettlementAdjustment, Report)))
        {
            reportName = ssrsReportStr(JPInventSettlementAdjustment, Report);
        }
      
        return reportName;
    }

}


This would be effective and simple to change the report design. hope this helps. I will come up with another interesting blog soon!