Download SSRS Report directly through X++

  Purpose:

The purpose of this document is to demonstrate how we can download report directly through X++ based on a business logic.

Product:

Dynamics 365 for Finance and Operations, Platform Update 9.

Development approach:

Customization through code, we need to directly download report 

Development:

Create a Controller class and using print destination helper class to download report

Please find the method definition as follows.


class  testTransController extends SrsReportRunController implements BatchRetryable
{
    SRSPrintDestinationSettings printDestinationSetting;
    public static void main(Args _args)
    {
         testTransController controller = new  testTransController();
        controller.parmReportName(ssrsReportStr(testTransReport, testTransOrig));
        controller.parmDialogCaption("test Bank Book Data Report");
        controller.startOperation();
    }
    // method to call print settings to download our generated report directly to downloads
    protected void preRunModifyContract()
    {
        testTransContract contract = this.parmReportContract().parmRdpContract() as testTransContract;
        
        
        this.parmReportContract().parmReportName(ssrsReportStr(testTransReport, BankBookTransOrig));
        printDestinationSetting = new SRSPrintDestinationSettings();
        printDestinationSetting.printMediumType(SRSPrintMediumType::File);
        printDestinationSetting.fileName(System.IO.Path::GetTempPath() +'test data report.XLSX');
        printDestinationSetting.fileFormat(SRSReportFileFormat::Excel);
        printDestinationSetting.overwriteFile(true);
       
        this.parmReportContract().parmPrintSettings(printDestinationSetting);
    }


}

Comments