Domino Code Fragment

Code Name*
Retrive one level of Child Documents from Parent Documenst using GetChild.
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.21.231.245
Description*
The example below will demonstrate how to retrieve information from a parent document, along with any child (response) documents associated with the parent document.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
The example below will demonstrate how to retrieve information from a parent document, along with any child (response) documents associated with the parent document. At this time, any grandchild (response to response) documents are ignored. Notice how documents are traversed using the NotesView method, GetNextSibling. The first parent document in the view is retrieved using GetFirstDocument, and is set to the object doc. Next, a child document is retrieved and set to the object child. To retrieve any other child documents, GetNextSibling is used, with child as a parameter. Using child as a parameter tells Notes `I have the first child document, now I want you to find the next child document'. After all of the child documents for the parent document have been retrieved, GetNextSibling is again executed with doc as a parameter. Using doc will get Notes to find the next document at the parent level.

Click here to view the example.

Dim session As New NotesSession 'Declare session as a new Notes session
Dim db As NotesDatabase
'Declare db as a Notes Database
Dim view As NotesView
'Declare view as a Notes View
Dim doc As NotesDocument
'Declare doc as a Notes Document
Dim child As NotesDocument
'Declare child as a Notes Document
Dim ParentText As Variant
'Declare ParentText as type variant
Dim ChildText As Variant
'Declare ChildText as type variant
Set db = session.CurrentDatabase
'Set db to the current database (open)
Set view = db.GetView("Examples")
'Set view to a view called "Examples"
Set doc = view.GetFirstDocument()
'Set doc to the first document in "Examples"
While Not(doc Is Nothing)
'Loop while there are still documents to process
ParentText = doc.Subject
'Set variable ParentText to the value in field Subject
Messagebox ParentText(0) + " **This comes from a parent document.**"

'Display a message that Subject is from a parent doc
Set child = view.GetChild(doc)
'Set child to the first child document
While Not(Child Is Nothing)
'Loop while there are still child documents of the current parent
ChildText = child.Subject
'Set variable ChildText to the value in field Subject
Messagebox ChildText(0) + "**This comes from a response document.**"

'Display the Subject field from the current child document
Set child = view.GetNextSibling(child)
'Set child to the next child document
Wend
Set doc = view.GetNextDocument(doc)
'Set doc to the next parent document
Wend