2013-07-05 42 views
1

我有一個包含大約20,000個文檔的數據庫。其中一個視圖按文檔編號分類並排序,以便最後創建的文檔是每個類別中的第一個文檔。某些類別(文件編號)只與文件相關聯,但其他文件則與文件相關聯。我想確定每個類別中最後創建的文檔,並寫入標識爲最新版本的字段。我認爲這很容易,但是,我有困難。任何幫助,將不勝感激。如何從共享相同文檔編號的文檔集合中識別使用Lotusscript創建的文檔?

MJ

回答

4

這可能是簡單的假設你有一個觀點,就像你說的,就是這樣整理,上創建的文檔是每個類別中的第一個文檔。在這種情況下,如果您要遍歷該視圖,則只需在每個類別之後檢索第一個文檔,並在文檔的其中一個項目上設置值。

例如,

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 
相關問題