Schedule.csp

To download the CSP files from this tutorial, click TutorialSamples_vb.zip. For more information about using the samples, see Code examples.


<HTML>

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

<BODY>

<!-- #include file=RetrieveIStore.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.


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


Dim Result

Dim IStore

Dim Error

Dim NewName

Dim ReportID, CurrentFolderID, Hours, Minutes


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

'previous page.

Hours = Request.Form("Hours")

Minutes = Request.Form("Minutes")


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

ReportID = Request.QueryString("ReportID")

CurrentFolderID = Request.QueryString("FolderID")


'Try to retrieve the InfoStore object.

If RetrieveIStore(IStore)= FALSE Then

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

  Response.Redirect "LogonForm.csp"


Else

  

  If ScheduleReport (IStore,ReportID,Hours,Minutes) = FALSE  Then

    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

  End If

End If


%>

</BODY>

</HTML>




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