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:

  1. Open the report criteria form and go into Design Mode.
  2. 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.
  3. Name the component BackgroundQueueTaskMenuItem.
  4. For the Caption, specify s&Background.
  5. Add a form event to generate the report in the background:
    1. With the menu item component selected, select the Events properties sheet.
    2. Click the ellipsis () button associated with the Primary property.
    3. In the Event Handlers dialog box, click New.
    4. In the Event Handler Properties dialog box, set the Event field to RunBackgroundQueue.
    5. For the Response > Type, select Run Form as Modal Child.
    6. Click the ellipsis button for Response > Parameters.
    7. Click Type Specific Parameters.
    8. In the Specify Form Run Options dialog box, from the Form drop-down list, select BackgroundQueue.
    9. Click Set Variables.
    10. In the Edit Set Variable Values dialog box, click New.
    11. In the Edit Set Variable Value Pair dialog box, specify these values:
      • Target = BGTaskName
      • Value = V(BGTaskName)
    12. Click OK.
    13. 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.
  6. In each dialog box, click OK, until you have been returned to the Event Handlers dialog box.
  7. If all event handlers for the form are not being displayed, click Show All.
  8. Modify the GenerateReport event handler:
    1. Select the GenerateReport event handler that has the Response Type of Run Background Task.
    2. Click Edit.
    3. In the Event Handler Properties dialog box, click the ellipsis () button associated with the Response > Paramters field.
    4. In the Event Handler Parms dialog box, click Type Specific Properties.
    5. If the Task Status field is not already set, set it to V(BGTaskStatus).
    6. If the Task Number field is not already set, set it to BGTaskNumber.
  9. Click OK repeatedly until you are returned to the form.
  10. Verify that the Primary field displays RunBackgroundQueue.
  11. Save and close the report criteria form.
  12. Refresh the metadata cache and then reopen the form.
  13. Verify that the Actions menu now includes a Background option for this form.
  14. Click the Background menu item and verify that the Background Queue form opens.
  15. 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.