Lotus Notes FAQ Visit Our Sponsor!

How do you track who deleted a document?


From Dirk Hamilton:
This is used to log each document deletion. It creates a log document which is displayed in a "deletion log" view so users can clearly see who deleted each document instead of pointing fingers :-)

Sub Postdocumentdelete(Source As Notesuidatabase)
  Dim s As New notessession
  Dim db As notesdatabase
  Dim d3 As notesdocument
  Dim c As notesdocumentcollection
  Dim d As notesdocument
  Set db = s.currentdatabase
  Set c = source.documents
  Set d = c.getfirstdocument
  Do 
    f = d.form
    If f(0) = "log" Then Goto skipper
    i = d.issue
    p = d.pkey
    'create log entry
    Set d3 = db.createdocument
    d3.form = "log"
    d3.when = Now
    d3.who = Evaluate("@Name([CN];@V3UserName)")
    d3.what = "Deleted a document. Form = " + f(0) + " :: issue = " + i(0) + " :: pkey = " + p(0)
    Call d3.save(True,False)
   skipper:
    Set d = c.getnextdocument(d)
  Loop Until d Is Nothing
End Sub


Applies to Notes Versions: 5 6 6.5 7
Last Modified: January 19, 2005