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 controller.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch); // Suppress report dialog controller.parmShowDialog(false); // Explicitly provide all required parameters rdpContract.parmReportStateDate(systemDateGet()); controller.parmReportContract().parmRdpContract(rdpContract); // Change print settings as needed settings = controller.parmReportContract().parmPrintSettings(); settings.printMediumType(SRSPrintMediumType::File); settings.fileFormat(SRSReportFileFormat::Excel); settings.fileName(@'\\share\UserLicenseCount.xlsx'); // Execute the report controller.startOperation(); |