Examples: GetNextDocument method (NotesView - LotusScript®)

  1. This script gets the second document in a view.
    Dim db As New NotesDatabase( "Istanbul", "contacts.nsf" )
    Dim view As NotesView
    Dim firstDoc As NotesDocument
    Dim secondDoc As NotesDocument
    Set view = db.GetView( "Main View" )
    Set firstDoc = view.GetFirstDocument
    Set secondDoc = view.GetNextDocument( firstDoc )
  2. This script shows how you can use a While loop and GetNextDocument to access every document in a view. The While loop exits when GetNextDocument returns Nothing, which means there are no more documents in the view. This construct is useful for a variety of cases; for example, this script checks to see that every document in the Open\By Due Date view is updated daily; if it isn't, the script sends mail to the document's authors.
    Dim db As New NotesDatabase _
    ( "Ankara", "current\projects.nsf" )
    Dim view As NotesView
    Dim doc As NotesDocument
    Set view = db.GetView( "Open\By Due Date" )
    Set doc = view.GetFirstDocument
    While Not ( doc Is Nothing )
      If doc.LastModified < Today Then
        Call doc.Send( True, doc.Authors )
      End If
      Set doc = view.GetNextDocument( doc )
    Wend