Examples: Responses property
These two scripts work together to place the currently open document (in the user interface) and its responses, including all responses-to-responses, in a folder. The first script is a form action script that the user can activate from a document on the workspace. It gets doc, the document on disk that corresponds to the currently open document, and places it in a folder of the user's choice. It then calls the PutAllResponsesInFolder sub.
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim choice As String
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
choice = Inputbox( "Please enter a folder name:", _
"Which folder?" )
Call doc.PutInFolder( choice )
Call PutAllResponsesInFolder( doc, choice )
End Sub
The PutAllResponsesInFolder sub takes a parent document and a folder name, and places the responses and responses-to-responses of the parent document into the specified folder. The sub places each response to the parent document into the specified folder. For each response, the sub calls itself to place any responses to the response into the folder. This recursive behavior allows you to access every descendant of the parent document, no matter how many levels deep it is nested. If there are no responses, the sub exits.
Sub PutAllResponsesInFolder _
( doc As NotesDocument, folderName As String )
Dim collection As NotesDocumentCollection
Dim currentResponse As NotesDocument
Set collection = doc.Responses
Set currentResponse = collection.GetFirstDocument
' Put immediate responses to doc into the folder
' If there are none, sub exits and returns to calling sub
While Not ( currentResponse Is Nothing )
Call currentResponse.PutInFolder( folderName )
' Recursive call to put immediate responses to
' currentResponse in folder
Call PutAllResponsesInFolder _
( currentResponse, folderName )
Set currentResponse = collection.GetNextDocument _
( currentResponse )
Wend
End Sub