ReportVar.RUNMODAL and Printer Setting

Hi folks,

I believe I have a unique question here, and could use your help. I have a report variable, and I call a function within the report, then to print it with ReportVar.RUNMODAL. The function I call sets a NoOfCopies variable within. What I want to do next is somehow control whether it prints to the Windows Printer, or uses the Printer Selection table.

I know that if I use the REPORT.RUNMODAL(xxxx,FALSE, FALSE,Record) that I can control the printer selection, but I don’t want to use this because I want to control the number of copies by running a function within the report.

Any suggestions on how I can specify whether to use the Windows Printer, or Printer Selection table using a report variable?

Thanks for any help.

Since NAV 2015 this can be achieved easily with the new command PRINT where you can define the printer name together with the report parameters and the recordref you wanna run with.

For older versions:

What you “could” do is actually three different approaches to this issue:

  1. (The ugly way) Create a Single Instance Codeunit which contains “SetNoOfCopies(INT)” and “GetNoOfCopies” functions. Declare a global “NoOfCopies” integer and make the SetNoOfCopies function set the value and GetNoOfCopies retrieving the value.
    Then you can set the NoOfCopies required just before the “REPORT.RUNMODAL(xxxx,FALSE, FALSE,Record)” statement.
  2. (not much better) Add a field to the record where you store the number of copies required and read it on the “OnAfterGetRecord”.
  3. (also clunky) If a “No. Printed” field exists, just do a SETRANGE on that field which you analyze and reset in the “OnPreReport” function.

Thanks Thomas. I already had figured out how to call a function in the report, in order to set the no.of.copies, but the problem that I am left with is controlling the “printing” of the report–that is, whether it uses the default windows printer, or the Printer Selection table. I know how it is done with REPORT.RUNMODAL(xxxx,FALSE,FALSE,recRecord), but don’t know a way to handle this using a report variable with SomeReport.RUNMODAL. Any ideas on this?

Thanks,

Chris

Hi Chris,

Which version of NAV are you using?

NAV 2013 RTC.

My post was not about calling a function in the report, that was exactly the point.

You are either calling a function in a SingleInstance CU and store the value there, then ask the same CU for that value when executed, or you hand over the no. of Copies with the Record value itself,

then you can still run with Report.RUNMODAL as usual AND hand over the NoOfCopies.

For 2013R2 I do not see another way.

GottchYa! Thanks