nongkook
nongkook

Reputation: 41

Is there a restriction on notes document collection and view?

I try to use NotesView.AllEntries.Count to get total document (total = 8,462)

but in my for loop index to total

when I print the index ==> it show far as 10975

enter image description here

What happen with program? and how ti fix this problem?

thanks a lot


edit : this is my code.

(move doc in current db to db history)

is it relate with doc conflict?

enter image description here

Upvotes: 0

Views: 592

Answers (1)

JSmart523
JSmart523

Reputation: 2497

NotesView.GetNthDocument documentation says "This method accesses only top-level (main) documents in a view; response documents are excluded."

Plus, @umeli is absolutely right. Think of it this way: Most people who can read and write know the first letter of their alphabet, and the 26th number, and they can instantly tell you what letter comes after "H", but they don't know the 20th letter off the top of their head. Ask them the 20th letter and they'll have to start with a number you DO know (like "A") and then count to the 20th step. So, in human brains, the alphabet is stored not as an array but as a linked list. NotesView and NotesDocumentCollection are the same. In most cases, GetNextDocument will be fast regardless of view size, but GetNthDocument will be fast at first and slower and slower.... GetNthDocument(1000) starts with the first document and counts to a thousand... then when you loop again it counts from the first to the 1,001st...

Instead use the following pattern:

Set doc = view.GetFirstDocument
Do Until doc Is Nothing
    'Do your thing here
    Set doc = view.GetNextDocument(doc)
Loop

... or in your case if you want to do something that removes documents from the view as you go...

Set doc = view.GetFirstDocument
Do Until doc Is Nothing
    Set docNext = view.GetNextDocument(doc) 'Get it early!
    'Do your thing here
    Set doc = docNext
Loop

This also has the advantage of working on response documents.

Not that you asked, but I also recommend that you write a function that works on the main document and then recursively calls itself on each of it's child documents, and then have your view only selecting main documents. That way, you can be more assured of moving a response hierarchy at a time.

Another thing you might want to do is set NotesView.AutoUpdate to False. This will help things run faster.

Upvotes: 1

Related Questions