Merge multiple NotesViewEntryCollection and sort on date

1.8k views Asked by At

I have some NotesViewEntryCollection that I want to merge into one collection, and then sort on date. All the collections are gathered from the same view, so there wont be a conversion problem.

Have tried to google this problem, but cant seem to find any good solutions, besides writing a bunch of for-loops.

Thnx in advance!

4

There are 4 answers

0
angryITguy On BEST ANSWER

Assuming that you're using LotusScript and a recent version of Notes (8+). You can use the merge method. The examples provided in the help, here, should help you get started. Be aware of some caveats when using NotesViewEntryCollections as reported by IBM.

The NotesViewEntryCollection gives you a sorted collection, and the merge method will also give you a unique sorted list of documents, unlike a regular NotesDocumentCollection which is just an unsorted bucket.

1
Paul Stephen Withers On

I found this out recently, that if you create a NotesViewEntry from one view, you can only add entries that exist in that view. So you can't combine entries from two different views.

A possible way round this would be to use a java.util.TreeMap, push the entries into the TreeMap with the date as the key. This may work, but you may need to convert the NotesViewEntry objects to your own non-Notes objects before adding them in. This will definitely be the case if you want to store them in a managed bean of session or application scope. No matter how you store them, if you use a TreeMap it will have a performance hit if you're dealing with a lot of entries.

0
Jasper Duizendstra On

It does not answer your question, but it might be possible to move all the documents to a (temporary) folder. This folder can take care of the sorting and merging.

0
Ken Pespisa On

If you are using Notes 8.0 or greater, there is a Merge method you can call to merge two collections together. Otherwise, you are correct that you'd have to loop through each collection and call AddEntry to add each entry one at a time.