Examples: ParentView property

  1. This script prints the title of the NotesView object from which a document was retrieved (view), and the title of the NotesView object returned by the ParentView property (parentView). The titles are the same, because view and parentView represent the same view, the Main View in .SOMEDOCS.NSF
    Sub Initialize
      Dim db As New NotesDatabase( "", "somedocs.nsf" )
      Dim view As NotesView
      Dim parentView As NotesView
      Dim doc As NotesDocument
      Set view = db.GetView( "By Category" )
      If Not view Is Nothing Then
        Set doc = view.GetFirstDocument
        Set parentView = doc.ParentView
        Messagebox view.Name , , "view.Name"
        Messagebox parentView.Name , , "parentView.Name"
      End If
    End Sub
  2. 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