Manage Learn to apply best practices and optimize your operations.

Convert A Notesdocumentcollection To An Array Of Notesdocuments

This will Convert a NotesDocumentCollection to an Array of NotesDocuments.
Sometimes we have a need to process two document collections as one list. This
will allow you to do that. First convert to an array with this script, then
combine the arrays. This example uses references to my my "Examples" database
in the code.

Option Public

Dim i As Integer
Dim doc As NotesDocument
Dim n As Integer, sorted As Integer
Dim s1, s2 As String
Dim docs() As NotesDocument

Sub CollectionToArray(col As NotesDocumentCollection, docs() As NotesDocument)

n = col.count
Redim docs(n-1) As NotesDocument

For i = 0 To (n-1)
Set docs(i) = col.GetNthDocument(i+1)

End Sub

Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim dt As New NotesDatetime("")
query = |Form = "Example"|

Set db = session.CurrentDatabase
Set dc = db.Search(query, dt, 0)
Print |There are | & dc.Count & | documents in the collection|
If dc.Count > 0 Then
Call CollectionToArray(dc, docs() )
Print |There are | & Ubound(docs) + 1 & | Documents in the new array|
Print "No Documents Selected"
End If

Dig Deeper on Domino Resources - Part 3



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury