Thursday, September 16, 2021

How to customise standard report in D365 FO

 Find the menu item, in my case I am taking "TaxTrans"

Create extension for same

go to the class on the menu item and create extension of same class, in my case my class was "TaxTransController"

I created a new extension class of controller class


class GITS_TaxTransControllerExt extends SrsReportRunController

{

    public static client void main(Args _args)

    {

        GITS_TaxTransControllerExt Controller;

        Controller = new GITS_TaxTransControllerExt();

        Controller.parmArgs(_args);

        Controller.parmReportName(ssrsReportStr(GITS_TaxTrans,Report));

        Controller.parmShowDialog(true);

        Controller.startOperation();

    }

}



Now dublicate the report in your project area and look for dp class

Now create a new extension class "GITS_TaxTransDP_Extension" for the DP class, in my case dp class was "TaxTransDP"

Also create extension of temp table and add the required fields

Write the following code and update logic accordingly


[ExtensionOf(classstr(TaxTransDP))]

final class GITS_TaxTransDP_Extension

{

    [PostHandlerFor(classStr(TaxTransDP), methodStr(TaxTransDP, processReport))]

    public static void TaxTransDP_Post_processReport(XppPrePostArgs args)

    {

        TaxTrans    lclTaxTrans;       

        TaxTransDP dpInstance = args.getThis() as TaxTransDP;

        TmpTaxTransReport lclTmpTaxTransReport = dpInstance.getTaxTransTmp();

        ttsbegin;

        while select forupdate lclTmpTaxTransReport

        {

            select sum(TaxBaseAmount) from lclTaxTrans

                where lclTaxTrans.Voucher   == lclTmpTaxTransReport.Voucher;

            lclTmpTaxTransReport.TaxBaseAmount  = lclTaxTrans.TaxBaseAmount;

            lclTmpTaxTransReport.update();

        }

        ttscommit;

    }

}



Now Build and deploy

Tada !!!