How select a printer automatically

DarkHorseDarkHorse Member Posts: 389
Hi, in "Posted Shipments" we have an option that is "Print/All" in which, in the user-defined printer, automatically print the packing slip and other related reports. But now we have different warehouses and depending on where you go out the items, we have to print to other printers that are physically in these warehouses Right now, when you click on "Print / All" makes a preview for each document, and you can select the printer manually. I'd like to know how do the following.
The best solution would be that, according to warehouse, it automatically prints to a printer or another (by code, I guess), so the user does not have to choose printer.
If that is not possible, I want to know if it's possible to select the printer once and print all the documents at once.
Thank you very much.

Comments

  • KishraguKishragu Member Posts: 45
    You can define the reports and the printers it needs to print on in "Printer Selection" table and do the coding accordingly.
  • sharadsharad Member Posts: 112
    You can code for this
    you can make the global variable of record type of printer selection table and set filter's and code to make your desired printer as default for a perticular report.
    Sharad Gupta
    Navision Technical Consultant & .Net Developer
  • DarkHorseDarkHorse Member Posts: 389
    Thanks both for reply. But, how can I do that? Can you put an easy example?. I don't know how select the printer by code, because I suppose that I have to put the "printer name". Neither want to duplicate reports and asign a different printer to each other, I know I could do like this.
    Thanks in advance.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    The general principle is that you create records in this "Printer Selection" table by code when you print the reports, assigning userid, reportid and printername. The last one can be obtained through the virtual Printer table.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for reply. Forgive my ignorance but I can't understand your answer. Can you put an example of doing it by code please?.
    Thanks in advance.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this link: http://lmsmfy.com/?q=printerselection , and have a look at the last topic which contains sample code.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DarkHorseDarkHorse Member Posts: 389
    Perfect!, thank your very much for your help!!!
  • DarkHorseDarkHorse Member Posts: 389
    Sorry, I've tested the examples and there is a thing that doesn't like me. I see that you have to delete de selected printer by code (on "printer selection") each time you want to print. It happends that the same report have to print in other printer in other process, then you have to put in each process by which printer do you want to print. Is it like this?.
    Thanks in advance.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    If you are able to create the Printer Selection record by code, you can also delete that record by code, can't you. If you don't need to add the Printer Selection record (because it's already there), you don't delete the record afterwards.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DarkHorseDarkHorse Member Posts: 389
    Thanks, but if I don't delete the printer it doesn't works; it always get the selected printer on "printer selection", or did I do something wrong?.
    Thanks.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Why not restore the Printer Selection table in the same state when you are finished with your code? If there were initially x-number records in the table, after your process and code executing the reports, the end result should be the same set of x-records in that table. During printing, you'll have to add or modify records though, to redirect the reports to the correct printer.

    Don't know what else can be said about this issue.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DarkHorseDarkHorse Member Posts: 389
    Thank you very much for responding. Yes, it's a good idea, so I will. But I do not like having to manually type the printer name in each process, as this can change, so you have to remember to change also all printing processes and change the printer name.
    Thinking about this subject, what would be printed by the printer to another user?, so you can create a dummy user and assign the printer you need in each process.
    Thanks in advance.
  • FDickschatFDickschat Member Posts: 380
    What Luc suggests definitely works and is not so hard to do.

    There is another possibility:
    • Add a field to the printer selection table (e.g. Warehouse Code) and add it to the primary key.
    • Add a SingleInstance CU, 2 Functions: SetWhseCode, GetWhseCode
    • In your PrintAll Report let the user choose the Warehouse and Call SetWhseCode before calling the single reports
    • Change FindPrinter in CU1:
      First command should be GetWhseCode
      Modify the PrinterSelection.Get with the additional Warehouse Code
      Last command should be SetWhseCode('') to reset the Warehouse Code in the SingleInstance CU

    You can now configure a Printer per User, Report and Warehouse.

    Of course you could also use this system to pass a dummy user (=warehouse code) to the FindPrinter Function. If you do so you can skip the modification to the primary key of the PrinterSelection table.
    Frank Dickschat
    FD Consulting
  • DarkHorseDarkHorse Member Posts: 389
    OK, I'll try this possibility. Thanks both.
    Thank your very much for help.
Sign In or Register to comment.