0
votes

I am working on IBM Domino 9.0 and currently developing an XPages application.

I have a Notes view that contains all the submitted documents by a user.

Now, I want to learn how to retrieve/get latest last two documents submitted by a user from a view. I want to display these documents in a Data-table.

2

2 Answers

2
votes

A quick and easy way would to have the notes backend view sorted with the most recent documents at the top. Then, a little bit of code to get the UNID of the first 2 documents for the specified user which you can then use to retrieve the documents for display in your data table. I'm sure there's probably a better way to do it though.....

0
votes

ViewNavigator.gotoLast() exists, which repositions the Navigator to the end of whatever collection you have created the ViewNavigator from. You can then use .getPrev(). I'm not sure on performance over large quantities of documents, but ViewNavigator is the quickest method of iterating a view.

If you just want comments within a time period, a NoteCollection will be the most efficient method.

But as Chris says, my preference would be to sort the view descending on date created instead. Then you just need to get the first two, which is much easier.