static void SR_SaveReportToPDFFromController(Args _args)
{
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); // Record id must be passed otherwise the report will be empty
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
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();
}