Designing a report to allow scheduling
Report criteria forms can be designed in such a way that the reports can be generated automatically, either on a one-time or a recurring basis. This, however, requires an additional procedure to be performed when creating them.
To allow a report criteria form to be used for scheduled report generation:
- Open the report criteria form and go into Design Mode.
-
From the Toolbox, select the MenuItem
component and then click inside the form area.
Note: When you add a menu item component to a form, it is, in effect, hidden; that is, there is no visible change to the form and the menu item component itself is not delineated on the form. If you lose focus on this type of component, to regain focus, you must select it from the Component drop-down list or from the Object Viewer.
- Name the component BackgroundQueueTaskMenuItem.
- For the Caption, specify s&Background.
-
Add a form event to generate the report in the background:
- With the menu item component selected, select the Events properties sheet.
- Click the ellipsis (…) button associated with the Primary property.
- In the Event Handlers dialog box, click New.
- In the Event Handler Properties dialog box, set the Event field to RunBackgroundQueue.
- For the Response > Type, select Run Form as Modal Child.
- Click the ellipsis button for Response > Parameters.
- Click Type Specific Parameters.
- In the Specify Form Run Options dialog box, from the Form drop-down list, select BackgroundQueue.
- Click Set Variables.
- In the Edit Set Variable Values dialog box, click New.
-
In the Edit Set Variable Value Pair dialog box,
specify these values:
- Target = BGTaskName
- Value = V(BGTaskName)
- Click OK.
-
Repeat substeps j.-l. to create a second variable value pair with these
value:
- Target = RunTaskEvent
- Value = GenerateReport
Note: "GenerateReport" is the name of the Run Background Task event that we want to schedule and be placed on the background queue. If you have been following the related topics, it should already have been created.
- In each dialog box, click OK, until you have been returned to the Event Handlers dialog box.
- If all event handlers for the form are not being displayed, click Show All.
-
Modify the GenerateReport event handler:
- Select the GenerateReport event handler that has the Response Type of Run Background Task.
- Click Edit.
- In the Event Handler Properties dialog box, click the ellipsis (…) button associated with the Response > Paramters field.
- In the Event Handler Parms dialog box, click Type Specific Properties.
- If the Task Status field is not already set, set it to V(BGTaskStatus).
- If the Task Number field is not already set, set it to BGTaskNumber.
- Click OK repeatedly until you are returned to the form.
- Verify that the Primary field displays RunBackgroundQueue.
- Save and close the report criteria form.
- Refresh the metadata cache and then reopen the form.
- Verify that the Actions menu now includes a Background option for this form.
- Click the Background menu item and verify that the Background Queue form opens.
-
Test the automatic generation of the report by performing these actions:
- Click the Once At option and set the time to a few minutes from now.
- Click OK.
If everything is set up correctly, you should get a "Report Submitted" confirmation message.
- After the scheduled time has elapsed, use the Background Task History form to verify that the report was generated at the correct time.