Reputation: 427
I have a database that contains about 20,000 documents. One of the views is categorized by Document Number and sorted such that the document created last is the first document in each category. Some categories (document numbers) only have on document associated with it, but others have multiply documents associated with it. I would like to identify the document created last in each category and write to a field indentifying it as the latest revision. I thought this would be easy, but, I'm having difficulties. Any help would be appreciated.
MJ
Upvotes: 2
Views: 1456
Reputation: 22266
It may be simple assuming you do have a view, as you say, that is sorted such that the document created last is the first document within each category. In that case if you were to traverse that view you would simply need to retrieve the first document after each category, and set a value on one of the document's items.
For example,
Dim s as New NotesSession
Dim db as NotesDatabase
Dim view as NotesView
Dim nav As NotesViewNavigator
Dim viewEntry as NotesViewEntry
Dim docEntry as NotesViewEntry
Dim doc as NotesDocument
Set db = s.CurrentDatabase
Set view = db.GetView("My Categorized and Sorted View")
Set nav = view.CreateViewNav
Set viewEntry = nav.GetFirst ' Should be your first category
While Not (viewEntry Is Nothing)
Set docEntry = nav.GetNextDocument(viewEntry) 'The first document entry after the category
Set doc = docEntry.Document
doc.ReplaceItemValue("Some item", "This is the latest doc")
doc.Save(false, false)
Set viewEntry = nav.GetNextCategory(viewEntry) 'Jump to the next category
Wend
Upvotes: 4