Lesson 4: Scheduling Reports
In Lesson 3 of this track, we ran published reports by using the Run and Advanced Run commands in the Server Console. Reports run in this way are on-demand reports. By contrast, Server also enables reports to be scheduled, that is, automatically run at one or more designated dates and times. Scheduled reports can greatly improve the performance of the reporting service in an organization. For example, you can run reports during low network traffic times. Scheduled reports can also capture a time period exactly, for example, the last day of the quarter.
Server does not deliver a scheduled report to an end user in the same way as it delivers an on-demand report. There are six destinations for scheduled reports:
- Versioning System
- File System
- Printer
- Fax
- FTP
In this lesson, we explore three of these:
- Example 1: Publish a Report to the Versioning System
- Example 2: Publish a Report to the File System
- Example 3: Publish a Report to the Printer
Example 1: Publish a Report to the Versioning System
The built-in versioning system is a virtual file system that Server maintains.
In this example, we set up a schedule to run a report immediately and ask Server to keep the generated result for 7 days. Even though we run the task immediately, we schedule to run the report through the Server scheduling system. This has two advantages, the user does not need to wait for the report to finish to continue using their system and Server runs the report in the background so does not impact other users who are running interactive reports. Another advantage of scheduling a report is that Server saves it in the versioning system; while normally Server does not save on-demand reports in the versioning system unless explicitly saved by the user.
- In the Resources page of the Server Console, go to the Public Reports > JinfonetGourmetJava folder.
- Put the mouse pointer over the OrderListbyDate_Parameter.cls report row, then select the Schedule button on the floating toolbar.
Server displays the General tab of the Schedule dialog box. It selects the report tab OrderDetails by default.
- Type ToVersion in the Schedule Name text box. Keep the default settings for other options in the tab.
- Select Next to go to the Parameter tab. You can specify new parameter values or keep the default values.
- Select Next.
- In the Publish tab, select To Version and then select Publish to Versioning System.
Server displays the publishing options:
- Select the Page Report Result format, select the Result Auto-delete check box and set Result Expires in 7 Days.
- Switch to the Conditions tab to specify the time when the task is to be performed.
- In the Time sub tab, keep the default selection, Run this task immediately, in the Time Type drop-down list. The Time Zone option should represent your current time zone.
- Select Finish to submit the task.
You can monitor the status of the report by viewing the My Tasks page (to access this page, select My Tasks on the system toolbar). Server lists the reports that are running in the Running table; when they complete running, Server moves them to the Completed table. Server lists the reports which are scheduled but have not yet run in the Scheduled table.
In this example, we publish the report result to the built-in version folder of the report. We can view the report result as follows:
- Put the mouse pointer over the OrderListbyDate_Parameter.cls report row, then select the Version button on the floating toolbar.
- In the Report Result Versions table, select the Page Report Result link in the Result column. Server displays the full page report result.
Example 2: Publish a Report to the File System
In this example, we set up a schedule to output a weekly sales report to the file system. We specify to run the report every Sunday night so it is available first thing on Monday morning.
- In the Resources page of the Server Console, go to the Public Reports > JinfonetGourmetJava folder.
- Put the mouse pointer over the CustomerContactCard.cls report row, then select the Schedule button on the floating toolbar.
- In the General tab, type ToPDF as the schedule name.
- Select the Publish > To Disk tab, and then select Publish to Disk.
- Select PDF. Server displays the PDF options.
- Keep the default location selection, Publish to Server Resource Tree, then type /CustomerContactCard.pdf in the text box below the location drop-down list. This publishes the report to the disk path of the server resource tree under the name CustomerContactCard.pdf.
The server disk path is
<install_root>\jreports
by default, thus if we want to place the output file in this folder, the path must start with a "/". Alternatively, we can type a full disk path if we want to create the file outside of the server resource tree, for example,C:\temp\CustomerContactCard.pdf
. - Select the Conditions tab to specify the time when to perform the task.
- In the Time sub tab, choose Run this task periodically from the Time Type drop-down list. Select Weekly from the Date drop-down list and define to repeat every one week on Sunday. Select At from the Time drop-down list and specify the time as 8:00 PM.
Although we do not use it in this lesson, the Notification tab enables you to specify e-mail notifications to be sent automatically when the report finishes running or if it is unable to complete successfully.
- Select Finish to submit the scheduled report request.
Since it isn't practical to wait until Sunday night to view the report in our lesson, we cheat a bit and request an early version of the report.
- In the Server Console, select My Tasks on the system toolbar. Server should display the report we requested above as a scheduled task.
- Put the mouse pointer over the task and select Run button on the floating toolbar to immediately schedule the report.
Now we can find the report result file "CustomerContactCard.pdf" using Windows Explorer in
<install_root>\jreports\
.
Example 3: Publish a Report to the Printer
In this example, we set up a schedule to output a form letter report to the printer on a monthly basis. We specify to send the form letter to delinquent customers.
- In the Resources page of the Server Console, go to the Public Reports > JinfonetGourmetJava folder.
- Put the mouse pointer over the ProductSalesAnalysis.cls report row, then select the Schedule button on the floating toolbar.
- In the General tab, type ToPrinter as the schedule name.
- Select the Publish > To Printer tab, then select Publish to Printer.
- Fill out the tab according to your requirements and the printer settings.
- Select the Conditions tab, and then select the Time sub tab to specify the time when the task is to be performed.
- From the Time Type drop-down list, choose Run this task periodically, select Monthly from the Date drop-down list and select to run the task on The 1st day of every 2 months at 7:00 AM.
- Select Finish to submit the scheduled report request.
- Select My Tasks on the system toolbar. Server lists the task in the Scheduled table. You probably want to delete this entry so Server does not print the report to your printer every month!