views:

2547

answers:

1

I am using the Lotus Notes 6.5.1 java API to read an .nsf file. Every document in the .nsf file has multiple document history. While traversing through the documents in the .nsf file using the LN java api I am getting all the document versions as separate documents. How do I ensure only the latest version of each document is retrieved by Lotus Notes? Is there a way to uniquely identify a document and all its version history as its children?

A: 

There is a built in feature for versioning documents in Notes Domino. Depending on hows it's configured in the database design (and assuming the database developer didn't roll there own) the versions will either be responses to an original parent, or the other way round, where new versions become the parent, with older versions being responses.

All this does however is to set up a response hierarchy in the database for you automatically when you edit the documents. How the rest of the database design interacts with this hierarchy is up to the developer.

What you probably want to do is create a view that only shows documents at the top of the response hierarchy. You can then traverse that view and know that the documents you get from it are the latest versions.

So if you have documents created with a form "Article" the view selection formula would be.

SELECT form*="Article" & !@IsAvailable($ref)

This selects all Article documents that are not responses. Now in code you can simply open the view and traverse it.

Once you have a handle on a document you can get its immediate child responses through

doc.getResponses()

Which returns a DocumentCollection that you can recurse down finding responses to responses. You can't get a parent document directly you first need to get its id with doc.getParentDocumentUNID() and then call db.getDocumentByUNID(). Of course you can combine that:

db.getDocumentByUNID(doc.getParentDocumentUNID())

In any case, you will have to look at what your database is actually doing, how it was originally designed and fit in with that.

kerrr