You create an OriginalSubject field on the Response form that inherits its value from the Subject field of the Main Topic. This works nicely, but you still have several Response documents with no value for Original Subject. You write this script to remedy the situation. It uses HasItem to check every Response in the main view of the current database for an item called OriginalSubject. If HasItem returns False, it uses AppendItemValue to create an item called OriginalSubject.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim mainDoc As NotesDocument
Dim responseDoc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "Main View" )
' get the first document in the view, which is a Main Topic
Set mainDoc = view.GetFirstDocument
' visit every Main Topic in the view
While Not ( mainDoc Is Nothing )
' get the first response to the Main Topic
Set responseDoc = view.GetChild( mainDoc )
' visit every response to the Main Topic
While Not ( responseDoc Is Nothing )
If Not (responseDoc.HasItem("OriginalSubject")) Then
' copy the Main Topic's Subject item into the
' Response's OriginalSubject item
Call responseDoc.AppendItemValue _
( "OriginalSubject", _
mainDoc.GetItemValue( "Subject" ) )
Call responseDoc.Save( True, False )
End If
' get the next response to the Main Topic
Set responseDoc = view.GetNextSibling( responseDoc )
Wend
' get the next Main Topic
Set mainDoc = view.GetNextSibling( mainDoc )
Wend