I have a form with a date field which is then put into a view. How can I create a new view that only displays documents created in the last seven days?
The best way to accomplish this without impacting view performance by using @Today is to add a field to new documents.
Modify the view selection formula to include DisplayIn7DayView="Yes".
When a new document is created, set a flag field to "yes." Have a hidden field "DisplayIn7DayView" with a default value of @If(@IsNewDoc; "Yes"; DisplayIn7DayView). This defaults the value to "Yes" for new documents but doesn't change it.
Create a nightly background process that walks the documents in the seven-day view, starting with the oldest. If the document was created more than seven days ago, set the field DisplayIn7DayView to "No." This will remove old documents. If the documents are less than seven days old, you can stop processing the view.
Another alternative is to include in the view selection formula:
@Created >= @Adjust (@Today;0;0;-7;0;0;0)Then you don't need to modify the form or run a nightly agent.
True, you don't need to modify the form or run a nightly agent, but instead just run @Today, a variation of @Now, the value of which changes every second. This means that the view would always require refreshing and rebuilding the index, which would put a load on the server. My solution only requires re-indexing when a new document is created or the night agent removes documents from the view.
Dig Deeper on Lotus Notes Domino Application Development
Related Q&A from Brian Mahoney
Find out what types of calculations can be computed for a column in a Lotus Notes view and the best way to go about it with this expert response. Continue Reading
Find out why you can't use Formula language to include a doclink to a specific Lotus Notes view or database and need to use LotusScript instead. Continue Reading
Discover the reasons behind a Notes/Domino admistrator having trouble with disabled options in the "customize this view" section of his Lotus Notes ... Continue Reading