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
document.**"

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
Wend
'----------- Set child to the next child document in the view
Set child = view.GetNextSibling(child)
Wend
'---------- Set doc to the next parent document in the view
Set doc = view.GetNextSibling(doc)
Wend
This was first published in November 2000

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close