Printing reports from code in AX2012

How to print a report from X++ and change print settings in AX2012?

I have a concrete example for you – it should give a good idea how to do that even if your situation is a little bit different.

SrsReportRunController          controller = new SrsReportRunController();
SysUserLicenseCountRDPContract  rdpContract = new SysUserLicenseCountRDPContract();
SRSPrintDestinationSettings     settings;
// Define report and report design to use
controller.parmReportName(ssrsReportStr(SysUserLicenseCountReport, Report));
// Use execution mode appropriate to your situation
// Suppress report dialog
// Explicitly provide all required parameters
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
// Execute the report


  1. Hi Martin,

    I already done some similar kind of example. But in my case i am testing this through Job. Where i can set the report parameters (can take the parameter reference from VS ex:DatesetName_Parametername)in job. But how to use the dynamics parameters in X++ code. example code: This is working fine but i am unable to override default parameters added in query range(say itemid), its taking what is there in report run dailog

    static void GenerateSSRSansSave(Args _args)
    SrsReportRun srsReportRun;
    //SysMailer mailer = new SysMailer();

    srsReportRun = new SrsReportRun(“ReportName.Report1”);



    // Print to a file named ReportExample in HTML/PDF format.

    if( srsReportRun )
    info(“Report Saved”);

    Thanks In Advance.

  2. Martin,

    Thanks so much for this post it’s saved me! Been struggling with some custom printing stuff for a couple days now with 2012.

    I’m going to probably do a more detailed blog post based off of this.


  3. Whenever I run this I always get an info box that says:

    “The report has been successfully saved as: ”

    how do I suppress this message?

  4. Thanks. But how to run this code? My requirement is I would like to print AX 2012 reports to Excel file in batch mode. I will need to supply report parameters (like Source system, Sorty by, Start date, End date etc). How can I pass the parameters in this code? Appreciate any help. Thanks

  5. Hi,

    Thanks for the code.
    Have you ever encountered trouble using parmShowDialog(false) to suppress the prompt?
    I’ve tried on a (custom) report and the dialog always showed up. I had to use parmLoadFromSysLastValue(false) otherwise the showDialog boolean was overwritten…
    See ya!

    • Yes, I’ve seen it before. It’s apparently saved in the report state.

  6. Hello Martin,

    Could you give me a example for D365. Should I create a class for that code?

  7. Hi Martin,

    Do you know if it’s possible to print the report on both sides of a page w/ code?

Comments are closed.