Roger Harvest
Roger Harvest

Reputation: 460

Domino.NotesDocumentCollection - what order are the items in the collection in?

I'm maintaining a legacy VB6 app that processes messages from Lotus Notes databases. From an instance of NotesDatabase, we obtain a NotesDocumentCollection and loop through the messages thusly:

Set domCollection = domDatabase.AllDocuments
Set domDocument = domCollection.GetFirstDocument
'Do something with domDocument
Set domDocument = domCollection.GetNextDocument
'Continue until no more documents

My question: Is it possible to know what order the documents will be returned in with the GetFirstDocument and GetNextDocument methods?

Thanks!

Upvotes: 2

Views: 492

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

The NotesDocumentCollection created e.g. from AllDocuments is unsorted. If you look at the order then you might discover that documents appear in order of creation. But there is no guarantee for that and mostly not helpful anyway.

If you need a sorted list of documents use NotesViewEntryCollection instead together with a sorted view.

If you need only some of the fields from documents put them all in view's columns and access them with entry.ColumnValues. This way you get a much higher performance than reading every single document.

Upvotes: 7

Related Questions