Home > Dynamics Ax 2012 > Ax 2012 Reports (SSRS) Print Utilities

Ax 2012 Reports (SSRS) Print Utilities


This article gives the examples, to print the reports of Dynamics Ax 2012 (SSRS Reports), in different ways.

1)Sending the Ax report through mail.

2)Save the report as file in local computer. (example covered to save the report as .pdf file)

Mail the report

static void myJobPrintReportMail(Args _args)

{

SrsReportRun                        reportRun;

Query                               query;

SRSReportPrintDestinationSettings   SRSReportPrintDestinationSettings;

SRSPrintDestinationSettings         srsPrintSettings;

;

delete_from SRSReportPrintDestinationSettings;

reportRun = new SRSReportRun();

reportRun.reportName(“Vend.Report”);  //<ReportName>.<DesignName>

// Set printersettings

srsPrintSettings = reportRun.printDestinationSettings();

srsPrintSettings.printMediumType(SRSPrintMediumType::Email);

srsPrintSettings.emailTo(“mail@gmail.com”);

srsPrintSettings.emailAttachmentFileFormat(SRSReportFileFormat::PDF);

srsPrintSettings.emailSubject(strfmt(‘vendor report – %1’, systemdateget()));

srsPrintSettings.pack();

reportRun.showDialog(false);

reportRun.init();

reportRun.run();

}

Save the Report To PDF File

static void myJobPrintReportPDF(Args _args)

{

SrsReportRun                        reportRun;

SRSPrintDestinationSettings         srsPrintSettings;

SRSReportPrintDestinationSettings   SRSReportPrintDestinationSettings;

;

delete_from SRSReportPrintDestinationSettings;

reportRun = new SRSReportRun();

reportRun.reportName(“Vend.Report”);  //<ReportName>.<DesignName>

// Set printersettings

srsPrintSettings = reportRun.printDestinationSettings();

srsPrintSettings.overwriteFile(true);

srsPrintSettings.printMediumType(SRSPrintMediumType::File);

srsPrintSettings.fileFormat(SRSReportFileFormat::PDF);

srsPrintSettings.fileName(“D:\\Vendors.pdf”);

srsPrintSettings.pack();

reportRun.showDialog(false);

//reportRun.saveParameters();                         //For Report parameters

reportRun.init();

reportRun.run();

}

In case of Parameterized reports

If the report has parameters (Using Contract Class),

Use the following line, to read the parameters and save to the table called, SRSReportParameters

reportRun.saveParameters();

For the same parameters, provide the required values to run the report.

I have tried the example of Vendor Transactions report, with my customized version. This standard report has 4 parameters, have used same parameters and provided the values in SRSReportParameters table to run the report.

For clear idea, have a quick look in to the following picture.

Advertisements
Categories: Dynamics Ax 2012
  1. Prasanna
    October 17, 2012 at 10:45 am

    Thanks santhosh.

    i tried in sales quotation report by sending the report to customers but it is not working and showing no error message. is there any configuration needed.

  1. No trackbacks yet.

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: