This agent demonstrates a function that gets the parent view given
a Document object.Sub Initialize
Dim db As New NotesDatabase( "", "" )
Dim doc As NotesDocument
Call db.open( "snapper", "progwork2.nsf" )
Dim view As NotesView
Set view = db.GetView( "By Category" )
If Not view Is Nothing Then
Set doc = view.GetFirstDocument
Call printViewName (doc, "first doc in view")
End If
Dim dc As NotesDocumentCollection
Set dc = db.AllDocuments
If dc.Count > 0 Then
Set doc = dc.getFirstDocument
Call printViewName (doc, "first doc in collection")
End If
Set doc = New notesdocument (db)
Call printViewName (doc, "new doc")
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
Call printViewName (doc, "ui doc")
End Sub
Sub printViewName (d As NotesDocument, t As String)
Dim v As notesview
Set v = d.ParentView
If v Is Nothing Then
Messagebox "Document did not come from a view.", , t
Else
Messagebox "Document came from the " + _
v.Name + " view.", , t
End If
End Sub