ViewEntryCollection in Java: stampAll to Bulk-Edit, FTSearch to Narrow, Set Ops to Combine

ViewEntryCollection in Java: stampAll to Bulk-Edit, FTSearch to Narrow, Set Ops to Combine

Nov 21, 2026 546 words

You get a batch of view-ordered document entries with view.getAllEntries() or getAllEntriesByKey(key), and now you need to do something to them: set one field to the same value across all of them, narrow the range with a full-text search, or subtract “query B’s results” from “query A’s”.

The reflex is a loop — getDocument(), replaceItemValue, save on each. That works, but ViewEntryCollection has batch and set operations of its own, and in many cases one line is enough. The docs define it as “Represents a collection of view entries of type document sorted in view order.” — note “of type document”: it holds document rows only, no category or total rows.

This covers stampAll, FTSearch, and the set operations, plus the two edges of walking.


stampAll: set one field across the whole batch

To set one field on all the documents behind a batch of entries to the same value, no loop-and-save needed — stampAll is one line. The docs: “Replaces the value of a specified item in the documents of all the entries in a view entry collection.”:

view.setAutoUpdate(false);
ViewEntryCollection vec = view.getAllEntriesByKey("Pending");
vec.stampAll("Status", "Processed"); // every doc's Status set to Processed

It’s the same move as NotesDocumentCollection’s stampAll, just sourced from a view’s entries. To restamp a batch selected by key with a new status or a processed-timestamp, this is far cleaner than a loop.

FTSearch: narrow the collection in place

Once you have a collection, you can shrink it with a full-text search. FTSearch is, in the docs, “Conducts a full-text search on all entries in a view entry collection and filters the collection.” — it’s in place: after the search, the collection holds only the entries matching the query (given a full-text index). The query string stays in the Query property.

ViewEntryCollection vec = view.getAllEntries();
vec.FTSearch("urgent"); // vec now holds only entries whose text contains urgent

Set operations: combine two queries

This is where ViewEntryCollection is handier than DocumentCollection — intersect / merge / subtract let you combine two result sets:

  • intersect — keep only entries also in the other set.
  • merge — add the other set in.
  • subtract — remove the other set.

For a “this year’s orders, minus the already-archived” condition, select the two sets, then a.subtract(b) — cleaner than one complex key or formula. To take the entry at a position, use getNthEntry(n) (in view order); for the size, Count (a property, not a method). How to read each entry’s column values (without opening the document) is in ViewEntry.

Two edges: autoupdate and recycle

Before walking or batch-operating a collection, set the view’s setAutoUpdate(false). The docs warn that auto-update degrades performance and can invalidate the entries you’re holding, raising “Entry not found in index” — which you hit when you’re processing while someone else edits the view. Call refresh yourself when you want fresh data.

And in Java, every ViewEntry you walk out of the collection needs recycle() when done, or a big collection piles up C-layer handles until they exhaust; the discipline is in the Java recycle blow-up piece. To lazily walk a huge view (with category rows, needing performance knobs), that’s ViewNavigator’s job — see the Java ViewNavigator piece.

What about LotusScript and SSJS?

The same ViewEntryCollection:

  • LotusScript: NotesViewEntryCollection, with StampAll / FTSearch / Intersect / GetNthEntry — same behavior, no recycle; see the NotesViewEntry piece.
  • SSJS / XPages: NotesViewEntryCollection, the same stampAll / set operations; request-managed lifecycle, no recycle. The DocumentCollection version of these batch ops is in the SSJS DocumentCollection piece.
  • The Java-specific part isn’t the API (the methods are shared) — it’s the memory discipline: stampAll and the set operations are one line, but switch to a per-entry loop and each entry needs its own recycle — strong typing won’t remind you of that.

Sources

← Back to all posts