Purpose
The purpose is to demonstrate the working code sample for printing SSRS Report Directly To The Active Network Printer Using X++.
Prerequisite
- Document Routing Agent should be enable.
- There should be atleast one active network printer.
Please refer below link for installing the document routing:
Steps & Sample Code
You can modify below sample code as per your need.This is just a prototype.
[code language = “cpp”]
SrsReportRunController reportRunController = new SrsReportRunController();
dataContract = new AcxInvoiceDataContract();
reportRunController.parmReportName(ssrsReportStr(AcxInvoiceReport,dgsCredit));
reportRunController.parmDialogCaption(“Print CREDIT NOTE”);
args.menuItemType(MenuItemType::Output);
args.menuItemName(identifierStr(AcxCreditReport));
reportRunController.parmArgs(args);
reportRunController.parmLoadFromSysLastValue(false);
reportRunController.parmShowDialog(false);
dataContract.parmInvoiceId(custInvoiceJourLocal.InvoiceId);
dataContract.parmCopyName(“Original for Recipient”);
reportRunController.parmReportContract().parmRdpContract(dataContract);
reportRunController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Printer);
// here is i am selecting only first active printer but you can make it configurable
select firstonly netPrinters
where netPrinters.PrinterName == printname
&& netPrinters.Active == NoYesCombo::Yes ;
//here i am passing printer name
reportRunController.parmReportContract().parmPrintSettings().printerName(netPrinters.PrinterName);
reportRunController.parmExecutionMode((SysOperationExecutionMode::Synchronous));
reportRunController.startOperation();
[/code]