LotusScript FolderReferences property helps determine in which folders a document is stored

Technote (FAQ)


Question

Is there any way to determine in which folder(s) a document is stored? For example, when viewing a memo in the All Documents view of your mail folder, how can you determine what folder it is in?

Answer

An enhancement request to make this property accessible through the user interface has been submitted to Quality Engineering. This enhancement has been addressed in Notes 7.0 with the addition of a new @Command. Refer to the following technote for more information:


    "Details on New Mail Template "Discover Folders" Action and New @Command DiscoverFolders" ( #1201309)

For releases prior to 7.0, to determine in which folder a document is stored, you can use a LotusScript agent. Notes Release 5.x introduces the LotusScript FolderReferences property (of the NotesDocument Class), which is designed to quickly return which folder(s) a document is in.

In order to use the FolderReferences property in a database, you must copy two internal views from the Mail Template: ($FolderInfo) and ($FolderRefInfo). Additionally, the LotusScript FolderReferencesEnabled property (of the NotesDatabase class) must be enabled. This can only be done programmatically; there is no User Interface equivalent. The FolderReferences property only returns folder information for folders moved after the FolderReferencesEnabled property was enabled. An enhancement request to backfill the value for documents moved into folders before the property was enabled has been made with Quality Engineering as SPR# MMQN6DJFLW; however, there are no plans to add this functionality.

A suggested way to enable the FolderReferencesEnabled property is within the PostOpen event for the Database. This event is found in the Design category "Other", under Database Resources, and within the "Database Script" design element. For example:
    Sub Postopen(Source As Notesuidatabase)
    Dim DB As NotesDatabase
    Set DB=Source.Database
    If Not DB.FolderReferencesEnabled Then DB.FolderReferencesenabled=True
    End Sub

Example usage:

The below LotusScript agent returns a selected document's folders in a messagebox. The agent should be designed to act on selected documents.
    Sub Initialize
    Dim s As New notessession
    Dim db As notesdatabase
    Dim doc As notesdocument

    Set db=s.CurrentDatabase
    If Not DB.FolderReferencesEnabled Then DB.FolderReferencesenabled=True

    Set doc=db.UnprocessedDocuments.getfirstdocument
    Messagebox Implode(doc.FolderReferences, ", ")
    End Sub

Note: There is a reported issue where the FolderReferences property causes an error to occur when the property is applied to a document that has been placed within another user's Private folder. For more information on this topic, refer to document "FolderReferences Property Returns Error: "You Are Not Authorized to Perform That Operation"' ( #1099783).

Supporting Information:

Refer to the Domino Designer help for more information on the FolderReferences property, the FolderReferencesEnabled property, and the example script from the properties.

In Notes Release R4, you can code a LotusScript agent to search through all folders in the database to determine whether or not a document is present within any folders. This type of agent, depending on the number of folders and documents, can take some time to run.

For example, below is an example of an agent which returns, into an array, all of the folders in which the selected document is located. The agent must be designed to act on selected documents, and only one document will be acted upon by the agent. The agent is designed to return all of the document's folders in a String array called FoundInFolder. The code is not able to search within the Private folders that belong to other users.

Note: This script is meant as an example only. Lotus Support is not available to further customize the code within it.
    Sub initialize
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim dc As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim key As String
    Dim FoundInFolder ( ) As String

    Set db = s.CurrentDatabase
    Set dc = db.UnprocessedDocuments
    Set doc = dc.GetFirstDocument
    key = doc.NoteID
    i=0

    Forall nv In db.Views
    On Error 4005 Goto PrivateOnFirstUse
    'Error 4005 will occur when accessing the "Shared, Private on First use" design element
    ' stub. The above On Error call causes this element to be skipped
    If nv.IsFolder Then
    On Error 4005 Goto 0
    Set doc = nv.GetFirstDocument
    If Not (doc Is Nothing) Then
    Do
    If (key = doc.NoteID) Then
    Redim Preserve foundinfolder(i)
    Foundinfolder(i)=nv.name
    i=i+1
    End If
    Set doc = nv.Getnextdocument(doc)
    Loop Until (doc Is Nothing)
    End If
    End If
    PrivateOnFirstUse:
    End Forall
    End Sub

Related information

FolderReferences Property Returns Error
Details on New Mail Template "Discover Folders" Action


    Cross reference information
    Segment Product Component Platform Version Edition
    Messaging Applications IBM Domino Designer Not Applicable Windows 8.5, 8.0, 7.0, 6.5, 6.0, 5.0

    Historical Number

    180681

Rate this page:

(0 users)Average rating

Document information


More support for:

IBM Notes
Folders

Software version:

5.0, 6.0, 6.5, 7.0, 8.0, 8.5

Operating system(s):

Linux, Mac OS, Windows

Reference #:

1092899

Modified date:

2010-02-22

Translate my page

Machine Translation

Content navigation