Skip to main content

Examples: IsResponse property (NotesViewColumn - LotusScript)

  1. This agent checks if there are one or more responses-only columns in the By Category view of the current database.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim found As Variant
Set db = session.CurrentDatabase
Set view = db.GetView( "By Category" )
found = False
Forall c In view.Columns
If c.IsResponse Then
found = True
Exit Forall
End If
End Forall
If found Then
Messagebox _
( "There's at least one responses-only column." )
Else
Messagebox( "There are no responses-only columns." )
End If
End Sub
  1. This agent goes through a hierarchical view and creates a summary of each thread by "folding" the immediate responses of each parent document into the parent. It takes the column value of each response document, calculated by finding the position of the Responses-only column in the view, and appends it to the Body field of the parent. This creates a summary of the response in the parent. The script then deletes the response from the database.

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)