We can save the SSRS report as a PDF file using the below sample code
{
SalesInvoiceController salesInvoiceController;
SalesInvoiceContract salesInvoiceContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
ReportName reportName = “SalesInvoice.Report”;
select firstOnly custInvoiceJour;
args.record(custInvoiceJour);
salesInvoiceController = new SalesInvoiceController();
salesInvoiceController.parmReportName(reportName);
salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
salesInvoiceController.parmArgs(args);
srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName(‘c:\\SR_SalesInvoice.pdf’);
salesInvoiceController.runReport();
}
Also if the SSRS report needs to be sent as an Email that can be acheived as below
public static void main(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings printSettings;
SrsReportEMailDataContract emailContract;
controller.parmReportName(ssrsReportStr(AXSalesReportNew, AutoDesign1));
emailContract = new SrsReportEMailDataContract();
emailContract.parmAttachmentFileFormat(SRSReportFileFormat::PDF);
emailContract.parmSubject(“My Report”);
emailContract.parmTo(person@hotmail.com);
printSettings = controller.parmReportContract().parmPrintSettings();
printSettings.printMediumType(SRSPrintMediumType::Email);
printSettings.parmEMailContract(emailContract);
printSettings.fileFormat(SRSReportFileFormat::PDF);
controller.parmShowDialog(false);
controller.startOperation();
}
*This post is locked for comments