How to run SSRS report from X++ code in AX? 1. SRSReportRun

Since AX 2012 has been released for more than 5 years, this topic is not fresh any more. But it's always convenient to have that written down, so I can find the snipet of code just in case I forget.


SRSReportRun reportRun;
//Initialize reportRun with a specific report name and design.
reportRun = new SRSReportRun("Test.PrecisionDesign1");

//Set parameter, you can find the parameter name in visual studio

// If the property 'Dynamic filter' is set to yes, the parameter needs to set thru the report query. For example,
//query = reportRun.reportQueries().lookup(reportRun.currentQueryKey());
//query.dataSourceNo(1).addRange(fieldNum(SalesTable, SalesId)).value('so-000050');

//Run report, or use executeReport() (no dialog will pop up).

  • Simple and straightforward.
  • When print multiple reports to screen together, each one runs asynchronously which means user will see multiple reports pop up to screen. SRSReportRunController doesn't do this, modification is required if we need to.


  • When printing to screen, the parameter section cannot be completely hidden which makes it not that neat.

  • When there're multiple companies(legal entities) in AX, SRSReportRun always pass the default company of current user to report, even if the current company is different. So in this situation, SRSReportRun doesn't work. And I believe this is a bug.
As SRSReportRun has a defect I don't see any solution to work arround, I would suggest not use it. More than that, in AX 2012, we can use another class which works with the SysOperation framework, the new framework compared to old version.

This is the link to how to run report by using SrsReportRunController.

No comments:

Post a Comment