Printing a NAV Report to a Server Printer - NAV 2017

robbonickrobbonick Member Posts: 40
I would like to be able to take a Printer Name, stored in a setup table and send a NAV report to there for printing. Is the only possible way to do this via Job Queue Entries? Or is there a way to do this without scheduling a Job Queue Entry.

I have tried to make use of a Single Instance Codeunit to populate a TempReportSelection record, with the Report ID and the Printer Name (Server Printer).
This doesn't seem to work when I run it, and just asks me to specify the printer (local printer) I would like to print to. I think this is because our Group Policy has the printer setup with a different name, compared to the name of the printer installed on the server (despite them being the same printer).

Ideally I just want to be able to pass the Printer Name of the server printer, and ignore the locally installed printers completely.

Here is an example of my code...
WarehouseShipmentHeader.GET(ShipmentNo);

Location.GET(WarehouseShipmentHeader."Location Code");
Location.TESTFIELD("Shipment Document Printer Name");

SingleInstance.SetPrinterSelection(REPORT::"Whse. - Shipment", Location."Shipment Document Printer Name");

WarehouseShipmentHeader.SETRECFILTER;
WhseShipment.USEREQUESTPAGE := FALSE;
WhseShipment.SETTABLEVIEW(WarehouseShipmentHeader);
WhseShipment.RUNMODAL;

SingleInstance.SetPrinterSelection(REPORT::"Whse. - Shipment", '');

With the function in the Single Instance Codeunit code looking like this:
IF TmpPrinterSelection.GET(USERID,inReportID) THEN BEGIN
  IF inPrinterName <> '' THEN BEGIN
    TmpPrinterSelection."Printer Name" := inPrinterName;
  END ELSE
    TmpPrinterSelection.DELETE;
END ELSE IF inPrinterName <> '' THEN BEGIN
  TmpPrinterSelection.INIT;
  TmpPrinterSelection."User ID" := USERID;
  TmpPrinterSelection."Report ID" := inReportID;
  TmpPrinterSelection."Printer Name" := inPrinterName;
  TmpPrinterSelection.INSERT;
END;

Any help/ideas are much appreciated.
Sign In or Register to comment.