Examples: GetNextSibling method (NotesView - LotusScript®))
- This script gets the second main document in the Main View of
a database, skipping over any responses to the first main document.
- If the Main View is categorized and firstMainDoc is the only main document in its category, GetNextSibling returns Nothing, even if there are more main documents in other categories in the view.
- If the Main View is categorized and firstMainDoc is not the only main document in its category, GetNextSibling returns the next main document in the same category as currentDoc.
- If the Main View is not categorized, GetNextSibling returns the
next main document.
Dim db As New NotesDatabase( "Providence", "buddy.nsf" ) Dim view As NotesView Dim firstMainDoc As NotesDocument Dim secondMainDoc As NotesDocument Set view = db.GetView( "Main View" ) Set firstMainDoc = view.GetFirstDocument Set secondMainDoc = view.GetNextSibling( firstMainDoc )
- The script calculates an item value in a main document based on
item values in its response documents. Here, the total item in a main
document is calculated to be the sum of all the total items of its
responses. The script moves from one main document to the next and
from one response document to the next. The Main View is not categorized.
Dim db As New NotesDatabase( "Cape-Town", "richardj.nsf" ) Dim view As NotesView Dim parentDoc As NotesDocument Dim responseDoc As NotesDocument Set view = db.GetView( "Main View" ) Set parentDoc = view.GetFirstDocument ' Visit each main document in the view While Not ( parentDoc Is Nothing ) newTotal% = 0 Set responseDoc = view.GetChild( parentDoc ) ' Visit each of the parent's response documents While Not ( responseDoc Is Nothing ) subtotal = responseDoc.GetItemValue( "total" ) newTotal% = newTotal% + Cint( subtotal( 0 ) ) Set responseDoc = view.GetNextSibling( responseDoc ) Wend ' Put the new total onto the parent document Call parentDoc.ReplaceItemValue( "total", newTotal% ) Call parentDoc.Save( True, False ) Set parentDoc = view.GetNextSibling( parentDoc ) Wend