Why would NotesView.EntryCount be different to the number of documents in the view?

I have a number of views with selection formulas where the EntryCount is different to the number of documents. There are no documents I can’t see in the database, but reader fields are used. The db doc Count is the same as the number of documents I can see in a All docs view.

I’ve added the following simple code to an Action on various views and anywhere there is a selection formula the maxdocs count is larger then the number of documents processed. I’ve tried in few different database.

Dim ws As New NotesUiWorkSpace	

Dim uiview As NotesUIView

Set uiview = ws.CurrentView	



Dim thisview As NotesView

Set thisview = uiview.View



Dim Thisdoc As NotesDocument

Dim count As Long

Dim maxdocs As Long



Count = 0

maxdocs = thisview.EntryCount



Set thisDoc = thisview.GetFirstDocument

Do Until thisDoc Is Nothing

	Count = Count + 1

	Print "Document <" & Cstr(Count) & "> of <" & Cstr(MaxDocs) & ">."

nextdoc:

	Set thisDoc = ThisView.GetNextDocument(thisdoc)

Loop

Subject: Why would NotesView.EntryCount be different to the number of documents in the view?

Have you considered that ViewEntries are not necessarily documents?

All rows in a view including categories, totals and duplicatie entries due to multiple values are ViewEntries.

Consider a simple example:

  • A view is sorted on field F, multiple values as separate entries

  • The view contains two documents

→ A: Field F contains values A1, A2

→ B: Field F contains values B1, B2, B3

In your view there are only two documents, but there are five rows:

  • A1 → A

  • A2 → A

  • B1 → B

  • B2 → B

  • B3 → B

cheers,

Bram

Subject: RE: Why would NotesView.EntryCount be different to the number of documents in the view?

Bram, thanks for the reply.

That is initially what I thought as well but ruled it out since the views are not categorised, nor are multiple values show as separate entries. There are no totals columns. The different is significant eg in one db the ViewEntries returns 518 docs but the doc counter only show 300. I deleted 5 documents, the doc counter dropped to 295 but the ViewEntries remained at 513. I deleted all but one document and the doc count was 1 but the ViewEntries dropped to 218.!

I Deleted one of the views, ran fix up, compact, Updall, and pasted the view back. Same result.

Subject: More analysis and I’ve found the culprit…

If a views SELECT formula uses @IsResponseDoc document eg. SELECT Form = “Topic” | @IsResponseDoc then the view actually select ALL the response documents in the database not just those associated to the selected Topic documents. If the view is “show response documents in hierarchy” only the response documents associated to selected Topic documents are available in the view BUT the NotesView.EntryCount counts all the response document in the database.

The SELECT should use @AllDescendants not @IsResponseDoc.

Doh! Obvious really.

(Slaped my head a few times when I spotted that.)