How can I print a SSRS report from a method in X++?

Hi, I have an application created in C# that works with AX 2012 using webservices, I need to create a method to print a SSRS report from AX, I’m a novice in this, could you help me out please? I need to define also the printer settings to send it to the correct printer, I would appreciate your help, thank you!!

I’ve prepared an example for you: http://dev.goshoom.net/en/2013/11/printing-reports-from-code-in-ax2012/.

I tried your example and it works great with a few modifications (I’m sending the printer name, and it works).

However, the report that I’m trying to run receives a parameter using Args, trough a class that extends from SRSReportRunController, the main method in that class sends the Args and then calls startOperation method.

I checked the methods and there’s one called controller.parmReportRun() that accepts a SrsRunReportInterface, I’m trying to send Args using controller.parmArgs() and then controller.parmReportRun(the class that extends from SRSReportRunController) but it does not accept that class as parameter, could you help me out please? thank you so much!

I’m not sure what your main() method does. If it uses only methods from SRSReportRunController, just use the same code. If it uses methods implemented in the child of SRSReportRunController, replace SRSReportRunController in the example by the child class and call appropriate methods.

Ok, I got it now, I use now the class that extends from SRSReportRunController, however, is like skipping the controller.parmShowDialog(false), it’s still showing me the dialog, before start using the class, it was not showing that dialog, it was working I guess, is there any way to force the process to make it work? Thanks!

Either the showDialog is set to true after you set to false, or the logic displaying the dialog is overridden in the child class. I can’t say anything more specific because I don’t have the code available. Use debugger to see what’s actually happening.

It seems like I can’t edit my posts, anyway, I found the solution, instead of using controller.startOperation() just use controller.runReport(), THANKS A LOT Martin, it’s working great!!

One question, it works great if I run it from inside AX, but when I call that method from a webservice, on my web application, nothing happens, do I need to set some kind of permission to do this? thank you!

There surely is a security setup (see Services and AIF security and protection), but you should get an exception if something fails.

If the service is called but it doesn’t behave as expected, use debugger to see what’s happening.

I’ll check the article that you mention there; I haven’t been able to debug the webservice method from Visual Studio, it would be really helpful indeed, and no, I don’t get any error, thank you!

I was in the same situation with about showdialog, your solution is worked. thank you… :slight_smile:

However, I looked up my old reports, there’s no problem with startoperation… that’s strange…