Playing with SSRS report in dynamics ax 2012

here is the simple code that i have created 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();
    }
Advertisements

13 Responses to Playing with SSRS report in dynamics ax 2012

  1. Wim Van hoorde says:

    Hi Amir,

    This works fine as long as you don’t want to show data from another company. The X++ code takes the data from the company which is defaulted in your user options.

    How can I pass the company info so that the data from the correct company is shown. Passing the company parameter wasn’t succesfull in my case (maybe I messed it up myself :)).

    Thanks,

    Wim.

  2. luca dallari says:

    Hi
    Do you know how to save SSRS report that use FormLetter framework (for example SalesInvoice) to file?

  3. Hathout says:

    My reports were created in 2008 , it has no design name. How can I call from this codemy report name just “TDPInv “

  4. Hathout says:

    I Solve my Problem … Just add to the Report name PrecisionDesign1 , it will just read Correctly

  5. oslebeto says:

    hi, thanks for this method but, how is the process if i want to set a value in a report in a field of a query but not in a parameter own of the report?

    This question is because i have to generate a report automatically with a number of vendors inserted into a table and this field “AccountNum” is in a query of button to select of form to report parameters

      • oslebeto says:

        Thank for your answer,

        In this moment, i doing the test, I want send automatically a report by mail and i want take the mail of the customer that is set in the query, but this process is by code, because the user set a range of customer and system have to send a report to which one of the customers parametrized in the query, where I can change this functionality for to send the email?

        thanks very much…you know that the change between Ax 2009 and AX2012 is very large in reports!!

  6. aslam says:

    I am knew to AX,Can you tell me about what is the mean of Financial dimension
    why we use it ..base leval not in ax general words
    If anyone can help me understand this linking I would greatly appreciate it. I will check back for any replies or you can email me at Aslammd111@gmail.com Thanks

  7. MadPro says:

    Hi,

    I need email reports PDF by button. Can you give idea ” how manage bundle of report PDF at run time and email it email id ” like employees salary slip pdf to email.

  8. Eduardo Cabrera says:

    Hi !!, I have a problem beacuse when I wrote the code works very well, because I am a Administrator but for user can´t run the report, Do you know why ????

  9. raju says:

    how to create item in ax 2012

  10. David says:

    Hello, I have this output error message while runing:

    SRSReportParameter object not initialized.

    Code:

    SRSReportRun report = new SRSReportRun(“report.Design”);

    super();
    report.reportCaption(“report.Design”);
    report.init();

    report.reportParameter(‘SalesId’).value(SalesTable.SalesId);
    if(report)
    report.executeReport();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: