Manage Learn to apply best practices and optimize your operations.

Retrieve Information From A Parent Document In A View, And All Of The Parent's Child And Grandchil

This example demonstrates how to retrieve information from a parent document in
a view, and all of the Parent's child and grandchild documents. Once all the
child and grandchild documents have been accessed for a parent document , the
next parent and it's associated documents are processed.

Notice the NotesView method GetChild is used to set an object to the first
child document of a parent. GetNextSibling is then used to find any other
child documents. If the object is set to "", there are no more children, and
the code retrieves any grandchild documents. To retrieve the first grandchild
document, GetChild is used with child as a parameter. If a grandchild document
is found, GetNextSibling is used with grandchild as a parameter to retrieve all
the grandchild documents. This is done until grandchild is set to "", at which
time GetNextSibling with a parameter of doc is used to find the next parent
document in the view.

Notes that there are three loops in the example:

________________ Main doc
|________________ Child docs
|________________ Grandchild docs
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
'----------- Also called a responce document
Dim child As NotesDocument
'---------- Also called a responce to a responce
Dim grandchild As NotesDocument
Dim ParentText As Variant
Dim ChildText As Variant
Dim GrandChildText As Variant
Set db = session.CurrentDatabase
'-------- Change "Examples" to the name of your view
Set view = db.GetView("Examples")
Set doc = view.GetFirstDocument()
'-------- Set doc to the first document in the view
While Not(doc Is Nothing)
'-------- Loop until every doc in the view has been checked
ParentText = doc.Subject
Messagebox ParentText(0) + " **This comes from a parent document.**"

Set child = view.GetChild(doc)
'--------- Get the first child of the current doc
While Not(Child Is Nothing)
ChildText = child.Subject
Messagebox ChildText(0) + "**This comes from a response

Set grandchild = view.GetChild(child)
'---------- set grandchild to the first grandchild of the current child
While Not(grandchild Is Nothing)
GrandChildText = grandchild.Subject
Messagebox GrandChildText(0) + "**This comes from a
response to response document.**"
Set grandchild = view.GetNextSibling(grandchild)
'------------ Set grandchild to the next grandchild document in the view
'----------- Set child to the next child document in the view
Set child = view.GetNextSibling(child)
'---------- Set doc to the next parent document in the view
Set doc = view.GetNextSibling(doc)

Dig Deeper on Lotus Notes Domino Administration Tools

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...