RenameReport.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 ChangeReportName(ReportID ,IStore, Error, NewName)

'This function changes the name of a report given its

'ID and new name.

'

'Precondition:

'ReportID - The ID of the report.

'NewName - The new name for the report.

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

    

    'The query that will select the name of the report.

    Dim Query  

    

    'The result of the query.

    Dim Result

        

    'Retrieve the current name of the report.

    Query = "Select Top 1* 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

        'Change the name.

        result.Item(1).Title =NewName

                

        'Write the result back to the APS.

        Call IStore.Commit (Result)


        'Check if the write was successful.

        If Err.Number <> 0 then

            Error = Err.Number

            Exit Function

        End If

    End If

    

    'Indicate success.

    Error=0

End Function


Dim Result

Dim IStore

Dim Error

Dim NewName

Dim ReportID, CurrentFolderID


'Request the new name that the user entered in the text box

'on the previous page.

NewName = Request.Form("ReportName")


'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.Write "<META HTTP-Equiv='REFRESH' Content='0;URL=LogonForm.csp'>"

  Response.Redirect "LogonForm.csp"


Else

  'Try to change the name

   ChangeReportName ReportID,IStore,error,NewName

  If Error <> 0 Then

    Response.Write "There was an error and as" & _

    " a result I could not change the report's name."

  Else

    'If the name change 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