There is sometime a mixup in printer names between Netbios Names and DNS Names.  Also, you might want to have certain reports printed to certain printers only.  I installed a code after
[code htmlscript=”false”]IF NOT PrinterSelection.GET(USERID,ReportID) THEN
IF NOT PrinterSelection.GET(”,ReportID) THEN
IF NOT PrinterSelection.GET(USERID,0) THEN
IF PrinterSelection.GET(”,0) THEN;[/code]
to search for printers using both Netbios Names and DNS Names.
[code htmlscript=”false”]IF (PrinterSelection."Printer Name" <> ”) AND
NOT Printer.GET(PrinterSelection."Printer Name") AND
(COPYSTR(PrinterSelection."Printer Name",1,2) = ‘\\’) THEN BEGIN
IF UPPERCASE(COPYSTR(PrinterSelection."Printer Name",1,26)) =
‘\\PRINTSERVER.DYNAMICS.IS\’ THEN BEGIN
LookupPrinterName :=
‘\\PRINTSERVER\’ + COPYSTR(PrinterSelection."Printer Name",27);
PrinterFound := Printer.GET(LookupPrinterName);
END
ELSE
IF UPPERCASE(COPYSTR(PrinterSelection."Printer Name",1,14)) =
‘\\PRINTSERVER\’ THEN BEGIN
LookupPrinterName :=
‘\\PRINTSERVER.DYNAMICS.IS\’ +
COPYSTR(PrinterSelection."Printer Name",15);
PrinterFound := Printer.GET(LookupPrinterName);
END;
IF PrinterFound THEN
PrinterSelection."Printer Name" := Printer.Name
ELSE BEGIN
IF ISCLEAR(SystemNetwork) THEN
CREATE(SystemNetwork,TRUE,TRUE);
SystemNetwork.AddWindowsPrinterConnection(
PrinterSelection."Printer Name");
IF NOT Printer.GET(PrinterSelection."Printer Name") THEN
ERROR(Text50000,PrinterSelection."Printer Name");
END;
END;[/code]
Where
[code htmlscript=”false”]Text50000 =
"Printer for this report is not found: %1, restart NAV and try again.
If still unsuccesful please contact IT department."[/code]
and

Name DataType Subtype Length
PrinterSelection Record Printer Selection
Printer Record Printer
SystemNetwork Automation ‘Windows Script Host Object Model’.WshNetwork
LookupPrinterName Text 250
PrinterFound Boolean

The line SystemNetwork.AddWindowsPrinterConnection connects the computer to the network printer if so a restart of the NAV client should be enough to get things working.

 

Leave a Reply

%d bloggers like this: