Examples: UnLock method (NotesDocument - LotusScript®)

This view action attempts to unlock the current document. Unlocking is successful if the effective user is one of the lock holders.

Sub Click(Source As Button)
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Set db = session.CurrentDatabase
  REM Exit if locking is not enabled
  If Not db.IsDocumentLockingEnabled Then
    Print "Document locking not enabled"
    Exit Sub
  End If
  REM Get selected document
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  REM Unlock document
  REM Document is not unlocked if error is raised
  On Error Goto errh
  Call doc.UnLock
  Print "Document unlocked"
  Exit Sub
  Print "Document NOT unlocked"
  Exit Sub
End Sub