Scheduling a report on the server

  1. Retrieve the entire report from the APS using a query that includes the report's ID.
  2. Use the SchedulingInfo object to gain access to the report's scheduling options.
  3. Set the scheduling options as required.
  4. Schedule the report using the member function Schedule provided by InfoStore.

Note:    The scheduling options in this tutorial allow you to generate report instances. However, if a report includes parameters or requires the user to log on to a database, the instance may fail or not return the desired report information unless you add more advanced functionality to the scheduling page. This is because scheduling uses the parameter and database logon information that is currently stored with the report object. If you want to change the report's parameter and logon information, you must use the ReportParameter Object and ReportLogon Object.

ScheduleReport function


Function ScheduleReport(IStore, ReportID, Hours, Minutes)

'This function schedules a report.

'

'Precondition:

'IStore - The InfoStore object that allows us to query.

'ReportID - The ID of the report that is to be scheduled.

'Hours - How often the report should be scheduled in hours.

'Minutes - How often the report should be scheduled in minutes.

'

'Notes:

'The function returns TRUE if successful and FALSE otherwise.


On Error Resume Next

  Dim Result


  'Query for the report's scheduling options.  

  Set Result= IStore.Query( "Select SI_SCHEDULEINFO From CI_INFOOBJECTS Where SI_ID="&ReportID)

  Dim Obj


  'Check that you have an object.

  If Result.Count = 0 then

    ScheduleReport=False

    Exit Function

  End If

    


  'Retrieve the report from the InfoObjects collection.

  Set Obj= Result.Item(1)


  If Err.Number <> 0 then

    ScheduleReport=FALSE

    Exit Function

  End If


  Dim ScheduleInfo

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

  Set ScheduleInfo = Obj.SchedulingInfo

  If Err.Number <> 0 then

    ScheduleReport=FALSE

    Exit Function

  End If



  'Set schedule options.    

  ScheduleInfo.IntervalHours = Hours

  ScheduleInfo.IntervalMinutes = Minutes

  'Indicate the report is to be scheduled hourly.

  ScheduleInfo.Type = 1  

  

  

  'Tell the APS to schedule the report.

  IStore.Schedule Result

  If Err.Number <> 0 then

    ScheduleReport=FALSE

    Exit Function

  End If

  ScheduleReport=TRUE

End Function


Remarks

This section of code queries for the report's SI_SCHEDULEINFO collection, giving you access to the SchedulingInfo object's properties and methods. Note that when changes are made through the SchedulingInfo object, they are actually being made to the SI_SCHEDULEINFO collection. This makes it possible for the InfoStore to write the changes back to the server using the original result set from the query.

The SchedulingInfo object reveals a myriad of different scheduling options of which only the most basic are used in this tutorial. For more information on the scheduling options available when using this object, see SchedulingInfo Object.

End of lesson

You've reached the end of the lesson. What follows is Schedule.csp, a file that includes the ScheduleReport function that you just looked at. To learn how to schedule reports that contain parameter values, see .

Go to next step:

Lesson 3e: Building a Report Details page



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