Adding the RetrieveIStore function

At this point, you should have a general idea about how to check for and retrieve the InfoStore object. Create a new CSP page and save it as RetrieveIStore.csp. Add the following function.

RetrieveIStore function

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


<%


Function RetrieveIStore(IStore)

'Precondition:

'None

'

'Postcondition:

'IStore - Returns the InfoStore object that allows us to query the server.

'

'The function returns TRUE if successful and FALSE otherwise.

On Error Resume Next


Dim LogonToken

Dim SessionManager

Dim Sess


'Check to see if the cookie is there.

If( Request.Cookies("LogonToken") <> "" ) Then

    

    'Check to see if the InfoStore already exists.

    If( TypeName(Session("IStore")) <> "ISInfoStore" ) Then

    

            'Retrieve the cookie.

            LogonToken = Request.Cookies("LogonToken")

            

            'Create a session manager.

            Set SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr")

            

            'Logon using the token.  This may fail if the token is no longer valid.

            Set Sess = SessionManager.LogonWithToken(LogonToken)

            

            'Create the InfoStore object.

            Set IStore = Sess.Service("", "InfoStore")


            'Save the InfoStore in the session.

            Session("IStore") = IStore


            RetrieveIStore = TRUE

            

    Else

            'The InfoStore already exists so simply retrieve it from

            'the session.

            Set IStore = Session("IStore")

            RetrieveIStore = TRUE

    End If

Else

    RetrieveIStore = FALSE

End If

End Function


%>


Remarks

Since you must have the InfoStore object to query the APS, you will want to include the RetrieveIStore function on any page that retrieves folders, reports, and/or report instances. You can do this by using a Server Side Include (SSI) statement such as the following:

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

Note:    Server Side Includes are supported by ASP/CSP. They are essentially the same as normal include files found in C and C++ programming environments. For more information, please refer to an ASP programmer's guide.

Go to next step:

Lesson 2a: Navigating through folders



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