Setting scheduling options for the printer

The scheduling options for printing an instance to a printer are handled somewhat differently. While FTP, SMTP, and disk are all handled by a separate plugin, the scheduling options for the printer are handled by the Report plugin. The report object owns an object called ReportPrinterOptions for this purpose. The object requires the following information:

The following code sets the report to print all pages when it has run:

PrinterOptions = Report.PluginInterface("").ReportPrinterOptions;

PrinterOptions.Copies = 1;

PrinterOptions.Enabled=true;

PrinterOptions.FromPage = 0;

PrinterOptions.ToPage = 0;

PrinterOptions.PrinterName = "\\vanprt\DocPrinter";

Note that to print the instance you must enable the printer options. If you do not, the report will be scheduled and run, but its instance will not be printed. Once you have set the printer options, you can schedule the report using InfoStore.Schedule. The complete example is given below.You can now choose to go to:

Example

function ScheduleToPrinter(PrinterName, Copies, FromPage, ToPage)

{

    var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID="+ReportId);

    if (Reports.Count == 0)

    {

        return;

    }

    var Report=Reports.Item(1);

    

    var ScheduleInfo ;

    //Create an interface to the scheduling options for the report.

    ScheduleInfo = Report.SchedulingInfo;

    // Run the report once.

    ScheduleInfo.Type = 0;

    // Run it right now.

    ScheduleInfo.RightNow = true;

    

    PrinterOptions = Report.PluginInterface("").ReportPrinterOptions;

    PrinterOptions.Copies = Copies;

    PrinterOptions.Enabled=true;

    PrinterOptions.FromPage = FromPage;

    PrinterOptions.ToPage = ToPage;

    PrinterOptions.PrinterName = PrinterName;

    

    

    //Tell the APS to schedule the report.

    IStore.Schedule (Reports);

}



Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com