D365/AX7:Print SSRS Report Directly To The Active Network Printer Using X++

Purpose

The purpose is to demonstrate the working code sample for printing SSRS Report Directly To The Active Network Printer Using X++.

Prerequisite

  1. Document Routing Agent should be enable.
  2. There should be atleast one active network printer.

Untitled

Please refer below link for installing the document routing:

https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/analytics/install-document-routing-agent

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]

 

 

 

Leave a Reply