AJF
AJF

Reputation: 1921

Find last created document in view

I am trying to create a view in Domino to find the last created document in each category. The Domino database holds records on college class reports and I have created a view with the first column as CollegeClass and the second column as DateCreated and the third column as ReportTitle. The CollegeClass column can have multiple entries of reports obviously and what I want to do is use a Lotus Notes Formula on the DateCreated column to only show the last report for each College Class. I have tried using @created in a few ways but no success as yet. How do I filter this to only show the latest report?

Upvotes: 1

Views: 436

Answers (2)

JSmart523
JSmart523

Reputation: 2497

If this is a Notes client application (and maybe if it's a web app, too) then your best bet is to make two views. One that shows what you want (except it shows all reports, but shows the latest report first), and the other being a folder with the same view columns.

Then write a LotusScript script library that has a function that sets/clears this LatestReportInCategory field so that this second view shows exactly what you're desiring. I imagine the function would...

  1. Get a NotesViewEntryCollection of all docs in in that folder.
    (e.g. Set col = db.GetView("LatestReportsPerCategory").AllEntries)

  2. Get a NotesViewNavigator object for the view.

  3. Use the NotesViewNavigator to walk through the getting the first document in each category and...

    Set doc = entry.Document
    doc.PutInFolder "LatestReportsPerCategory"
    col.Subtract doc

  4. After walking through the view this way, all of the documents you want in the second view will appear there, but we haven't yet cleared the LatestReportInCategory field for any reports that used to belong in the second view. However, all of those extra documents are now the only documents within the NotesDocumentCollection because we've subtracted all of the ones that belong, so you can now do
    col.RemoveAllFromFolder "LatestReportsInCategory"

Once you've got that working, you can call that function from an agent that runs on New/Modified documents, or nightly, from the save and/or delete event of report document, or any other time it's appropriate. Also, if used via Notes Client, set the folder's QueryAddToFolder event to return False since want code, not users, changing this folder.

Upvotes: 0

Knut Herrmann
Knut Herrmann

Reputation: 30960

You can't achieve this with a view. A document in a view can't be hidden in dependence of another document.

Upvotes: 1

Related Questions