Examples: Remove method (NotesDocument - LotusScript®)

  1. This script removes a document from a database, unless another user has modified it.
    Dim doc As NotesDocument
    '...set value of doc...
    If doc.Remove( False ) Then
      Messagebox _
      ( "The document was deleted from the database." )
    Else
      Messagebox _
      ( "Doc not deleted. Another user modified it." )
    End If
  2. This script removes a document from a database, regardless of whether another user has modified it. It does not use the Remove method's return value.
    Dim doc As NotesDocument
    '...set value of doc...
    Call doc.Remove( True )
  3. This script gets the universal ID of the current UI document, marks the document for deletion and closes it. The script then retrieves the back-end NotesDocument object from the database and removes it with the NotesDocument Remove method.
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim docA As NotesDocument
    Dim s As String
    
    Set db = session.CurrentDatabase
    Set uidoc = workspace.CurrentDocument
    Set docA = uidoc.document
    s = docA.UniversalID
    Call uidoc.deletedocument()
    Set docB = db.getDocumentByUNID(s)
    Call docB.Remove(True)
    Call workspace.viewrefresh()
  4. This script removes all of the documents in the view called "My Favorites."
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim collection As NotesViewEntryCollection
    Dim entry As NotesViewEntry
    Dim doc As NotesDocument
    Set db = session.CurrentDatabase
    Set view = db.GetView("My Favorites")
    Set collection = view.AllEntries
    Set entry = collection.GetFirstEntry()
    While Not(entry Is Nothing)
      Set doc = entry.Document
      doc.Remove(True)
      Set entry = collection.GetNextEntry(entry)
    Wend