RenameReport.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=helper_js.csp -->

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

<%

function ChangeReportName(ReportID ,IStore, 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.


//Postcondition:

//Function returns true if it was successful and false otherwise.

    

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

    var Query;  


    //The result of the query.

    var Result;

            

    //Retrieve the current name of the report.

    Query = "Select SI_NAME, SI_ID From CI_INFOOBJECTS Where " +

    "SI_ID=" + ReportID;

        

    //Query the server.

    Result = IStore.Query(Query) ;

    

    if ( Result.Count > 0 )

    {

        //Change the name.

        Result.Item(1).Title=NewName;

            

        //Write the result back to the APS.

        try {

            IStore.Commit (Result);

        }

        catch(e) {

            return false;

        }

    }

        

    //Indicate success.

    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;


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

//on the previous page.

NewName = Request.Form.Item("ReportName");


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

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

//Retrieve the ID of the folder that is being displayed.

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.

    Response.Write ("<META HTTP-Equiv='REFRESH' Content='0;URL=LogonForm.csp'>");

    RedirectWithFrames ("LogonForm.csp");

}

else

{

    //Try to change the name

    if (!(ChangeReportName (ReportID,IStore,NewName)))

    {

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

    }

}


%>

</BODY>

</HTML>



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