【问题标题】:How can I identify the document created last using Lotusscript from a collection of documents that share the same document number?如何从共享相同文档编号的文档集合中识别上次使用 Lotusscript 创建的文档?
【发布时间】:2013-07-05 15:49:35
【问题描述】:
我有一个包含大约 20,000 个文档的数据库。其中一个视图按文档编号分类并排序,以使最后创建的文档是每个类别中的第一个文档。某些类别(文档编号)仅具有与之关联的文档,但其他类别具有与其关联的多个文档。我想确定每个类别中最后创建的文档,并将其写入一个字段,将其标识为最新版本。我以为这很容易,但是,我遇到了困难。任何帮助将不胜感激。
乔丹
【问题讨论】:
标签:
lotus-notes
lotus-domino
lotusscript
【解决方案1】:
假设您确实有一个视图可能很简单,正如您所说,该视图经过排序,最后创建的文档是每个类别中的第一个文档。在这种情况下,如果您要遍历该视图,您只需要检索每个类别之后的第一个文档,并为文档的其中一个项目设置一个值。
例如,
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