Setting Maximum number of documents in a view

I have a view that i want to show last 5 entries. How do I limit the number of documents are selected in the view?

Subject: Setting Maximum number of documents in a view

If this is a web view, you can sort the view’s first column descending on date created or modified (whatever date you are using to determine the last 5) and then use the &count=5 parameter in the url when opening the view.

This post from Stan Rogers seems to rain on the parade of doing this in the Notes Client directly.

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/f3d5b7fd58a8680d8525708e0045e7ea?OpenDocument&Highlight=0,latest,documents

One thing you can do, however, is set an agent to run whenever a document is created. First… create your view and in the view selection, look for a flag field to be set (say, SELECT showInView = “True”). In the form, Call an agent that, if the document is being saved for the first time, gets the OLDEST document in the view, and changes the flag to “”. Be sure to check the number of entries in the view and only do this if you actually have at least 5 documents in the view (otherwise, you would always be removing your oldest entry and not have more than one document in the view). The showInView field can be set in the same script or it can simply be a CWC field with the value “True” in the computation.

This will have the effect of showing the 5 most recent documents in the view because they will be the only ones with this flag set.

Subject: Setting Maximum number of documents in a view

If this is a web view, you can sort the view’s first column descending on date created or modified (whatever date you are using to determine the last 5) and then use the &count=5 parameter in the url when opening the view.

I will think about a way to do this in the Notes Client and post another reply.

Subject: Setting Maximum number of documents in a view

I don’t recommend you do it the way Joel has suggested. This is going to cause a lot of replication conflicts and a lot of replication traffic:

One thing you can do, however, is set an agent to run whenever a document is created. First… create your view and in the view selection, look for a flag field to be set (say, SELECT showInView = “True”). In the form, Call an agent that, if the document is being saved for the first time, gets the OLDEST document in the view, and changes the flag to “”. Be sure

Instead, hardcode a view selection formula as follows:

SELECT Form = “X” & @IsMember(@Text(@DocumentUniqueID);“xxx”:“yyy”:“zzz”)

Then use your agent to gather the five most recently created documents, and update the selection formula accordingly. Run the agent every 30 minutes or so.

Of course, you should not assume, as I do above, that there are at least three documents to display in total. There could be fewer than that, and your agent should handle such a scenario.

You could do the same thing with a folder.