Scheduling a report on the server

To schedule a report on the server, follow these steps:

  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.



  var Result;


  //Query for the report's scheduling options.  

  Result = IStore.Query( "Select SI_SCHEDULEINFO From CI_INFOOBJECTS Where SI_ID="+ReportID);

  var Obj;


  //Check that you have an object.

  if ( Result.Count == 0 ) {

    return(false);

  }

    


  //Retrieve the report from the InfoObjects collection.

   Obj= Result.Item(1);


  var ScheduleInfo;

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

   ScheduleInfo = Obj.SchedulingInfo;

  

  //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.

  try {

    IStore.Schedule (Result);

  }

  catch(e)

  {

        return (false);

  }

  return(true);

}

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 Viewing a report containing specific parameter values.

Go to next step:

Lesson 3e: Building a Report Details page



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