Adding a query function

The next step is to query the server using the Query Method that is provided by the InfoStore object.

Set Result = IStore.Query(Query)

Remarks

The result, which is an InfoObjects collection, is parsed in order to retrieve the selected items. The InfoObjects collection contains numerous properties of various types, some of which may be simple properties and some of which may be containers or property bags. A property bag may contain more property bags, which may contain additional property bags, and so on. For now, however, only two of these properties are of interest:

Processing the results of the query

The final step in this function is processing the results of your query using the Count and Item properties named above. If Count is greater than zero, then the parameters IDs and FolderNames will be populated with the requested data. Paste the following code into your file to finish the function.

Example


Dim k

    

    'Check that there are folders to view.

    If Result.Count > 0 Then

    'Reallocate the array to make room for the folder names.

    Redim FolderNames(Result.Count)

    Redim IDS(Result.Count)

    

        'Retrieve the folder IDs from the query result.

        k = 1

        Dim oFolder

        For each oFolder in Result

          FolderNames(k)=oFolder.Title

          Ids(k)=Result.Item(k).ID

          k = k+1

        Next


    End If


Remarks

Note that the ID property is accessed directly without using the Properties collection. More often than not, however, the Properties property will need to be used in order to access properties in the list. This will be illustrated later in Creating an "Up a Level" link.

RetrieveChildFolders now provides us with a list of child folders given their parent folder's ID number. You may recall, however, that your original intention was to list all the top-level folders. How do you go about doing this? Folders on the top level have no parent, thus their SI_PARENTID is zero. When the folder page is initially loaded, you call RetrieveChildFolders like this:

RetrieveChildFolders(IStore, 0, FolderNames, IDs)

For a complete version of the RetrieveChildFolders function, see Folders.csp.

Go to next step:

Retrieving the parent folder



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