Domino Code Fragment

Code Name*
NotesDocumentCollection class
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.145.17.46
Description*
The example below uses GetFirstDocument and GetNextDocument to display the title of documents in the Intermediate view that contain the word "NotesDocumentCollection".
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Like views, the NotesDocumentCollection class supports methods for processing documents within it, including GetFirstDocument, GetNextDocument, GetLastDocument, GetPrevDocument, and GetNthDocument. The methods work identically to their NotesView counterparts.

When a subset of documents has been collected into a NotesDocumentCollection, GetFirstDocument and GetNextDocument can be used to move through all of the documents in the collection, regardless of document type. (Document, Response, Response to Response) The GetFirstDocument method is capable of retrieving only the first document in a NotesDocumentCollection. GetNextDocument is then used to traverse the rest of the documents in the NotesDocumentCollection. In order to keep track of which document was the last document retrieved, GetNextDocument uses the document object reference variable (doc) as a parameter.

Click here to see the example.

Dim session As New NotesSession 'Declare session as a new Notes session
Dim db As NotesDatabase
'Declare db as a Notes Database
Dim view As NotesView
'Declare view as a Notes View
Dim doc As NotesDocument
'Declare doc as a Notes Document
Dim UpIndex As Integer
'Declare UpIndex as type integer
Dim GotSubject As Variant
'Declare GotSubject as type variant
Dim collection As NotesDocumentCollection
'Declare collection as a Notes document collection
Set db = session.CurrentDatabase
'Set db to the current Notes database (open)
Set view = db.GetView("Intermediate")
'Set view to a view called "Intermediate"
If db.IsFTIndexed Then
'If a full text index is set
UpIndex = Messagebox("Update database full text index before searching for documents?",51,"Create Index?")
'Ask the user if they wish to update the index
If UpIndex = 6 Then 'If "Yes" (return value = 6)
Call db.UpdateFTIndex(True)
'Update the index
End If
End If
Set collection = db.FTSearch("""NotesDocumentCollection""", 0)
'Set collection to the result of the FTSearch
Set doc = collection.GetFirstDocument
'Set the first document in the collection to doc
While Not (doc Is Nothing)
'Loop while there are still documents to process
GotSubject = doc.ChapterTitletxt
'Put the value from the field ChapterTitletxt into the variable GotSubject
Messagebox Cstr(GotSubject(0))
'Display the ChapterTitle
Set doc = collection.GetNextDocument(doc)
'Set doc to the next document in the collection
Wend