ReportDescription.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 RetrieveReportInformation(ReportID, IStore, Error, Name, Description)

'This function retrieves the name and description of a particular report

'given its ID number.  


'Precondition:

'ReportID - The ID of the report currently being viewed.

'IStore - The InfoStore object required to interface with server.

'Error - A variable to hold the error if one occurs.


'

'Postcondition:

'Error - Contains the error number: 0 if successful.

'Name - The name of the report.

'Description - A description of the report.


    'The query that will select the report details.

    Dim Query  


    'The result of the query.

    Dim Result

        

    'A query that selects report details.

    Query = "Select SI_NAME, SI_DESCRIPTION From CI_INFOOBJECTS Where " & _

     "SI_ID =" & CStr(ReportID)

        

    

On Error Resume Next

    'Query the server.

    Set Result = IStore.Query(Query)

    If Err.Number <> 0 Then

        'There was an error querying the server.

        Error = Err.Number

        Exit Function

    End If

    

    If Result.Count > 0 Then

        'Retrieve the name.

        Name=Server.HTMLEncode(Result.Item(1).Title)


        'Retrieve the description.

        Description=Server.HTMLEncode(Result.Item(1).Description)

    End If

    'Indicate success.

    Error = 0

End Function


Function RetrieveReportInstances(ParentID ,IStore, Error, LogonToken)

'This returns an HTML table that is populated with the instance name,

'description and the last time it was modified.

'

'Precondition:

'ParentID - The ID of the parent report containing the instances to be retrieved.

'IStore - The InfoStore object required to interface with server.

'Error - A variable to hold the error if one occurs.

'LogonToken - The user's logon token so that a link can be provided to view

'              each instance.


'

'Postcondition:

'Error - Contains the error number: 0 if successful.


'

'Notes:

'The function returns a string that is an HTML table.


    'The query that will select the instances.

    Dim Query  

    'The result of the query.

    Dim Result

    'A string to hold the HTML table.

    Dim HTMLTable

    HTMLTable=""

        

    'Create a query that selects all the instance objects (SI_INSTANCE_OBJECT=1).

    Query = "Select SI_NAME, SI_ID, SI_UPDATE_TS From CI_INFOOBJECTS Where " & _

    "SI_INSTANCE_OBJECT = 1 AND SI_PARENTID=" & CStr(ParentID)

    

    

        

On Error Resume Next

    'Query the server.

    Set Result = IStore.Query(Query)

    If Err.Number <> 0 Then

        'There was an error querying the server.

        Error=Err.Number

        Exit Function

    End If

    

    

    If Result.Count <> 0 Then

        'Set up the table header.

        HTMLTable="<table border=0 width = ""100%""><TR><TD><B>Name</B></TD>" & _

                                "<TD><B>Last Modified</B></TD></TR>"

        

        

        Dim oDescription

        For Each oDescription in Result

        'Add the instance name and details to the table.    

        'Ensure that each name is a link to the viewer.


            HTMLTable=HTMLTable & _

            "<TR  valign=top><TD>" & _

            "<A Target='_blank' href='viewrpt.cwr?id=" & oDescription.ID & _

            "&apsToken=" & Server.URLEncode(LogonToken) & "' >" & _

            Server.HTMLEncode(oDescription.Title) &  "</A></TD>" & _

            "<TD>" & oDescription.Properties("SI_UPDATE_TS") & "</TD></TR>"

            

            Next

        HTMLTable=HTMLTable&"</table>"

    End If

    RetrieveReportInstances    =HTMLTable

    

    'Indicate success.

    Error=0

End Function


Dim IStore

Dim CurrentReportID, CurrentFolderID

Dim Error


'Retrieve the CurrentFolderID from the file's parameter list.

CurrentReportID = 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

  Dim Name, Description


  'This is the link back to the folder view listing all the reports.

  Response.Write "<a href='reports.csp?FolderID="&CurrentFolderID & _

            "'><font size=-1>&lt&lt View Report Listing</font><P><a>"


  RetrieveReportInformation CurrentReportID, IStore, Error, Name, Description

  If error=0 then

    Response.Write "<B><font size=+2>" & Name & "</font></b>"

    

    'Draw the thumbnail in a table so that it has a border and scale

    'it to be a little smaller.

    Response.Write "<P><TABLE Width='100%'><TR VAlign='Top'><TD>" & _

               "<TABLE Border=1><TR><TD><CENTER><B>Preview</B></CENTER>" & _

               "<IMG Width=159 Height=206 " & _

            "SRC=""thumbnail.csp?ReportID=" & CurrentReportID &" ""></TD>" & _

            "</TR></TABLE></TD>"


    'Write the report's description.

    Response.Write "<TD>" & Description & "</TD></TR></TABLE>"

    

    'Write out the instances associated with the report.

    Response.Write "<BR><B><FONT Size=+2>Instances</FONT></B>"

    Dim Instances

    Dim LogonToken

    'Retrieve the logon token so that the instances can be viewed in the report viewer.

    LogonToken = Request.Cookies("LogonToken")

    Instances = RetrieveReportInstances( CurrentReportID,IStore,Error,LogonToken)

    If Error=0 then

        If Instances="" then

            Response.Write "<BR>There are no instances of this report." & _

             " Schedule the report to create an instance of it."

        Else

            Response.Write  Instances

        End If

    Else

        Response.Write "Error: I could not retrieve the instances of this report."

    End If


    'Write the links that enable the user to view, rename or schedule a report.


    'View

    Response.Write "<HR><CENTER><A Target=""_blank"" HRef=""viewrpt.cwr?id=" & _

                CurrentReportID & "&APSToken="&LogonToken&"""> View Report</A> - "


    'Rename

    Response.Write "<A HRef='ChangeReportNameForm.csp?ReportID="&CurrentReportID & _

                "&ReportName=" & Server.URLEncode(name) & "&FolderID="& CurrentFolderID & _

                "'>Rename Report</A>"


    'Schedule

    Response.Write " - <A HRef='ScheduleForm.csp?ReportID="&CurrentReportID & _

                "&" & "FolderID=" & CurrentFolderID &" '>Schedule Report</A></CENTER>"

  Else

    Response.Write "There was an error trying to retrieve the report details."

  End If

  

End If


%>

</BODY>

</HTML>




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