Wednesday 1 January 2014

Controller class in ax 2012 to print the SSRS report

here is the simple code  to print the SSRS report in dynamics ax 2012 from different scenarios.

How to print the SSRS report in dynamics ax 2012 from code.

    SrsReportRun srsReportRun;

    // initiate the report.
    srsReportRun = new SrsReportRun ("InventTruckTransactionReport.PrecisionDesign1");
    srsReportRun.init();
    srsReportRun.reportCaption("InventTruckTransactionReport.PrecisionDesign1");
    // set parameters name, value.
    srsReportRun.reportParameter("TruckTransDS_JournalId").value("000161_070");
    // suppress the dialog
    srsReportRun.showDialog(false);

    if( srsReportRun )
    {
        // run the report 
        srsReportRun.executeReport();
    }

How to save the SSRS report to PDF/HTML through code in dynamics ax 2012.

    SrsReportRun srsReportRun;

    srsReportRun = new SrsReportRun("InventTruckTransactionReport.PrecisionDesign1");

    srsReportRun.init();
    srsReportRun.reportCaption("InventTruckTransactionReport.PrecisionDesign1");
    srsReportRun.reportParameter("TruckTransDS_JournalId").value("000161_070");
    srsReportRun.showDialog(false);

    // Print to a file named ReportExample in HTML/PDF format.
    srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File);
    srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF);
    srsReportRun.printDestinationSettings().overwriteFile(true);
    srsReportRun.printDestinationSettings().fileName(@"C:\InventTruckTransactionReport.pdf");

    if( srsReportRun )
    {
        srsReportRun.executeReport();
    }

1 comment:

  1. Here is Mr Benjamin contact Email details, 247officedept@gmail.com. /  Or Whatsapp +1 989-394-3740 that helped me with loan of 90,000.00 Euros to startup my business and I'm very grateful,It was really hard on me here trying to make a way as a single mother things hasn't be easy with me but with the help of Mr Benjamin put smile on my face as i watch my business growing stronger and expanding as well.I know you may surprise why me putting things like this here but i really have to express my gratitude so anyone seeking for financial help or going through hardship with there business or want to startup business project can see to this and have hope of getting out of the hardship..Thank You.

    ReplyDelete