Schedule.csp

To download the CSP files from this tutorial, click TutorialSamples.zip. For more information, see Code examples.

<%@ Language=JavaScript%>

<HTML>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

<BODY>

<!-- #include file=RetrieveIStore.csp -->

<!-- #include file=helper_js.csp -->

<%



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);

}

function RedirectWithFrames(URL)

{

    Response.Write ("<script language=javascript>open (\""+URL+"\",\"_top\");</script>");

}

var Result;

var IStore;

var Error;

var NewName;

var ReportID, CurrentFolderID, hours, minutes;


// Request the hours and minutes that the user entered on the

// previous page.

hours = Request.Form.Item("hours");

minutes = Request.Form.Item("minutes");


//Retrieve the report ID from the page's parameter list.

ReportID = Request.QueryString.Item("ReportID") ;

CurrentFolderID = Request.QueryString.Item("FolderID");


//Try to retrieve the InfoStore object.

IStore = RetrieveIStore();

if (IStore == null )

  //If it failed, redirect the user to the logon page.

  RedirectWithFrames ("LogonForm.csp");


else

{

  if ( ScheduleReport (IStore,ReportID,hours,minutes) == false  )

    Response.Write ("There was an error and as" +

    " a result I could not schedule this report.");

  else

    // If the scheduling was successful then send the user back

    // to the report details page.

  Response.Redirect ("ReportDescription.csp?ReportID=" + ReportID + "&FolderID=" +

    CurrentFolderID);

  }



%>

</BODY>

</HTML>



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