Press ESC to close

Add Report Format to Print Management in D365

In this article, we will look at how we can call our custom report using Print Management.  

What is print management? Print management in D365 FO X++ is a powerful tool for managing and customizing your report designs. It provides a flexible way to control how your reports are printed and distributed.  

Most of the time we would get the requirement to get the custom business document/report in the Print management form setup. To fulfil this requirement first of all we would create the design as we have created in our previous article. In this article we add our custom report design for the project invoice proposal format in the print management form setup. By default, there is the attached design in the setup if we go to the following path:  

Project management and accounting -> Setup -> Forms -> Form setup -> Print Management -> Project invoice without billing rules ->  

image-145.png  

To add a custom design firstly we have to find the document type beyond that design, I have written a query below in SQL Server:  

select * from PrintMgmtReportFormat
	where name = 'PSAProjInvoice.Report'

There are two different ways to call our custom design using print management form setup i.e., using event handler or chain of command  

Using Event Handler  

Step # 1: Copy the event handler of the getDefaultReportFormatDelegatemethod of the PrintMgmtDocTypeclass and subscribe to its event handler.  

image-146.png  

Step # 2: Create a new class and paste it. After it add logic in the method to call our custom report.  


internal final class MDPrintMgmtDocTypeHandler
{
    [SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void PrintMgmtDocType_getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {
        switch (_docType)
        {
            case PrintMgmtDocumentType::SIProjInvoice:
                _result.result(ssrsReportStr(MDPSAProjInvoice, Report));
                break;
        }
    }
}

Using Chain of Command  

Step # 1: We need to create COC of the addDocuments method of the PrintMgmtReportFormatPopulator class.  

[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))]
public final class MDPrintMgmtReportFormatPopulator_Extension
{
    protected void addDocuments()
    {
        #ISOCountryRegionCodes
        #PrintMgmtSetup

        next addDocuments();

        Add new customized document
        this.addOther(PrintMgmtDocumentType::SIProjInvoice, ssrsReportStr(MDPSAProjInvoice, Report), ssrsReportStr(MDPSAProjInvoice, Report), #NoCountryRegionId);
    }
}

Result: After build and synchronize the solution, go to Project management and accounting -> Setup -> Forms -> Forms setup -> Print management -> Project invoice without billing rules:  

image-147.png