Assumptions:
- There are no responses-to-responses in the view.
- The view contains one responses-only column, and it displays pertinent information about the response (such as the Subject).
Sub Initialize
Dim db As New NotesDatabase( "", "corn.nsf" )
Dim view As NotesView
Dim responsePos As Integer
Dim doc As NotesDocument
Dim rtitem As Variant
Dim response As NotesDocument
Dim tempResponse As NotesDocument
Set view = db.GetView( "All" )
' find the position of the Responses-only column
Forall c In view.Columns
If c.IsResponse Then
responsePos = c.Position
End If
End Forall
Set doc = view.GetFirstDocument
' visit each main document in the view
While Not( doc Is Nothing )
Set rtitem = doc.GetFirstItem( "Body" )
Set response = view.GetChild( doc )
' visit each response to the main document
While Not( response Is Nothing )
' fold the response's column value into the parent
Call rtitem.AppendText _
( response.ColumnValues( responsePos - 1 ) )
Call rtitem.AddNewLine( 1 )
' save a temporary copy of current response...
Set tempResponse = response
' ...so that the script can get the next response...
Set response = view.GetNextSibling( response )
'...and then delete the current response.
Call tempResponse.Remove( True )
Call view.Refresh
Wend
Call doc.Save( True, True )
Set doc = view.GetNextSibling( doc )
Wend
End Sub
For example, the All view might contain one main document and three responses. The subject and author of each response is displayed in a responses-only column:
What's your favorite color? (Shelley Kinnamon)
Blue (Joe Doyle)
Purple (Peg Yip)
Orange (Kendra Zowker)
The script removes the three responses so that only the main document remains in the database:
What's your favorite color? (Shelley Kinnamon)
The Body of the main document now contains the following text:
Blue (Joe Doyle)
Purple (Peg Yip)
Orange (Kendra Zowker)