2014-02-14 2 views
1

2 가지 범주의보기가 있습니다. 두 번째 레벨 카테고리 각각의 첫 번째 항목과 마지막 항목을 가져 오는 방법은 무엇입니까? 문제는 뷰의 각 항목을 반복하려고하므로 GetAllEntriesByKey를 사용하지 않는 것입니다. GetAllEntriesByKey를 사용하는 경우 결과 항목 컬렉션에서 GetFirstEntry 및 GetLastEntry와 함께 사용할 수 있기 때문에 더 쉽습니다. 그러나 문제는 어떤 키도 사용하지 않고 전체보기를 반복하려는 것입니다. 나는 다음을 시도했지만 나는 항상 'Object Variable Not Set'을 주석 처리하고 처음 실행시 실패했다. 코드가 'Loop'인 곳에서 'Object Variable Not Set'을 만나기 전에 절대로. 일반적으로 이전 문서가 삭제 된 경우 GetNextDocument에만 적용됩니다. 오해를 피하기 위해Lotusscript는보기의 범주에 대한 첫 번째 및 마지막 문서/항목을 가져옵니다.

Dim s As New NotesSession, db As NotesDatabase 
Dim vw As NotesView, vec As NotesViewEntryCollection 
Dim ve As NotesViewEntry, doc1 As NotesDocument, doc2 As NotesDocument 
Set db = s.Currentdatabase 
Set vw = db.Getview("View with 2 level category") 
Set vec = vw.Allentries 
Set ve = vec.Getfirstentry() 
Do While ve.Document.Universalid <> vec.Getlastentry().Document.Universalid 
    Do 
     Set ve = vec.Getnextentry(ve) 
    Loop Until ve.Iscategory = False 
    Set doc1 = ve.Document 
    Do While ve.Iscategory = False 
     Set ve = vec.Getnextentry(ve) 
    Loop 'always get object variable not set here 
    Set doc2 = ve.Document 
    Print doc1.UserDepartment(0) 
    Print doc2.UserDepartment(0) 
    Set ve = vec.Getnextentry(ve) 
Loop 
  • , 나는 의미 2 수준의 범주는 1, 2 열은

답변

1

난 당신이 무엇을 달성하고자하는, 전혀 이해하지 못하는 분류 한 도면이다. ..하지만 :

모든 것을 순환하려면 NotesViewNavigator 클래스를 사용하십시오.

Dim ses as New NotesSession 
Dim db as NotesDatabase 
Dim viw as NotesView 
Dim viwNav as NotesViewNavigator 
Dim veCat as NotesViewEntry 
Dim veCatNext as NotesViewEntry 
Dim veDoc as NotesViewEntry 
Set db = ses.CurrentDatabase 
Set viw = db.Getview("View with 2 level category") 
Set viwNav = viw.CreateViewNav 
Set veCat = viwNav.GetFirst() 
While not veCat is Nothing 
    Set veCatNext = viwNav.GetNextCategory() 
    If veCatNext.IndentLevel < veCat.IndentLevel '- This is a subcategory of the given category 
    '- do whatever you want 
    '- e.g. build a new viewnavigator from this using viw.CreateViewNavFromChildren 
    '- or get the first document by set veDoc = viwNav.getNextDocument(veCat) 
    Elseif veCatNext.IndentLevel = veCat.IndentLevel '- This is the same (sub)category 

    Else '- we are back to the next main category 
    End If 
    Set veCat = veCatNext 
Wend