Printer Selection on Terminal Server

foolosofo
Member Posts: 73
Hello,
we have some Navision Users that are connected directly to a computer via terminal server. Terminal server creates a "session x" of different printers of clients when they're logged in.
The problem is that I assign these printers to various users using Printer Selection to print various reports directly for selected printer. However, nothing is printed when I do some process that runs this report. I'm running the report using FALSE in RUN(..,..,SystemPrinter).
I can print reports for the printers added to TS if I run the report with Preview form but I need to print directly these reports without preview form. So, I don't know what's the problem.
Thank you.
we have some Navision Users that are connected directly to a computer via terminal server. Terminal server creates a "session x" of different printers of clients when they're logged in.
For example:
Client 1 have 2 local printers installed. When it's logged in to Terminal SErver, TS adds these 2 printers to the server with a session id.
Client 2 have 2 local printers installed, too. When it's logged in to TS, TS adds these 2 printers to the server with another session id...
..and so on...
The problem is that I assign these printers to various users using Printer Selection to print various reports directly for selected printer. However, nothing is printed when I do some process that runs this report. I'm running the report using FALSE in RUN(..,..,SystemPrinter).
I can print reports for the printers added to TS if I run the report with Preview form but I need to print directly these reports without preview form. So, I don't know what's the problem.
Thank you.
0
Answers
-
I believe there was a bug on printer name and it being not case sensitive. That could be the case.
The other option is that to add the printers to printer selection from logging into terminal services.0 -
Modify CU1
Invoice Datamax M-4206/PC01/Session 5
Define printers while session is active.FindPrinter(ReportID : Integer) : Text[250] CLEAR(PrinterSelection); 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; IF STRPOS(PrinterSelection."Printer Name",'/Sessio') > 0 THEN BEGIN PrinterSelection."Printer Name" := COPYSTR(PrinterSelection."Printer Name",1,STRPOS(PrinterSelection."Printer Name",'/Sessio')-1) ; Printers.SETFILTER(Printers.ID,PrinterSelection."Printer Name"+'*') ; IF Printers.FIND('-') THEN EXIT(Printers.Name); END ELSE EXIT(PrinterSelection."Printer Name");
0 -
In NAV 4.00 this is working as expected. So your tip is for earlier versions?0
-
My experience is it (still) does not work in 4.0 with terminals. I don't know for Citrix.0
-
Thank you all. I'll try this and I'll post my answer.0
-
I've solved this like Malajlo said. However I've done several adaptations to his code for language reasons and filtering problems.
FindPrinter(ReportID : Integer) : Text[250] CLEAR(PrinterSelection); 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; IF STRPOS(PrinterSelection."Printer Name",' en la sesi') > 0 THEN BEGIN PrinterSelection."Printer Name" := COPYSTR(PrinterSelection."Printer Name",1,STRPOS(PrinterSelection."Printer Name",' en la sesi')-1) ; IF Printers.FINDFIRST THEN REPEAT IF STRPOS(Printers.ID,PrinterSelection."Printer Name") > 0 THEN EXIT(Printers.Name); UNTIL Printers.NEXT = 0; END; EXIT(PrinterSelection."Printer Name");
Thank you!!!0 -
My little contribution to community...
Code above works for Win2003 or earlier. On Win2008, sessions and printer names are different.
To determine which session is logged in, it is in TEMP variableFindPrinter(ReportID : Integer) : Text[250] CLEAR(PrinterSelection); 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; //AX001 - Start IF STRPOS(PrinterSelection."Printer Name",'essio') > 0 THEN BEGIN PrinterSelection."Printer Name" := COPYSTR(PrinterSelection."Printer Name",1,STRPOS(PrinterSelection."Printer Name",'essio')-3) ; Printers.SETFILTER(Printers.ID,''''+PrinterSelection."Printer Name"+'*''') ; IF Printers.FIND('-') THEN EXIT(Printers.Name); END ELSE IF STRPOS(PrinterSelection."Printer Name",'redi') > 0 THEN BEGIN PrinterSelection."Printer Name" := COPYSTR(PrinterSelection."Printer Name",1,STRPOS(PrinterSelection."Printer Name",'redirected')+10)+ COPYSTR(ENVIRON('TEMP'),STRLEN(ENVIRON('TEMP')),1)+')' ; Printers.SETFILTER(Printers.ID,''''+PrinterSelection."Printer Name"+'''') ; IF Printers.FIND('-') THEN EXIT(Printers.Name); END ELSE //AX001 - End EXIT(PrinterSelection."Printer Name");
0 -
And for NAV2009 RTC, you have to change a few more lines of code.
I use an automation because there is a known bug with the printer detection.
Apparently if you login to Navision RTC within a few seconds after login via terminal service, your system will not detect all the redirected printer. Or course if you can train you users to wait n seconds before login to Navision (where n is = number of redirected * 3), or ask them to use classic Navision then the automation is not needed.
In Codeunit 1,
Name DataType Subtype Length
WshNetWork Automation 'Windows Script Host Object Model'.WshNetwork
//AX001 - Start
IF STRPOS(PrinterSelection."Printer Name",'redirected') > 0 THEN
BEGIN
CREATE(WshNetWork,FALSE,TRUE);
i := 1;
REPEAT
IF STRPOS(WshNetWork.EnumPrinterConnections.Item(i),'ZDesigner ZM400 200 dpi') > 0 THEN BEGIN
EXIT(WshNetWork.EnumPrinterConnections.Item(i));
END;
i := i + 1;
UNTIL i = WshNetWork.EnumPrinterConnections.Count;
END
ELSE
//AX001 - End
EXIT(PrinterSelection."Printer Name");0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions