This is how I have accomplished this task for various reasons. After looking through the Designer Help database and creating a log database, use the following code in the Querydocumentdelete sub of the Database Script. Also, you can grab as much data from as many fields as you would like. Further, you could implement a prompt for each document (inside the loop) or all documents (outside the loop) to have input for why the document was deleted.
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
Dim docsDelete As NotesDocumentCollection
Dim doc As NotesDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Set docsDelete = Source.Documents ' Docs chosen for deletion
Dim delLog As New NotesLog(db.FilePath)
For x = 1 To docsDelete.Count
Set doc = docsDelete.GetNthDocument( x )
Call delLog.OpenNotesLog("SERVERNAME", "pathname\loggingdb.nsf")
Call delLog.LogAction("The following user was deleted by " + session.CommonUserName + ": " + Cstr(doc.FirstName(0)) + " " + doc.LastName(0))
Call delLog.Close
'The following section emails a notification of the deletion
Dim maildb As NotesDatabase
Dim maildoc As NotesDocument
Dim rtitem As NotesRichTextItem
Set maildb = session.CurrentDatabase
Set maildoc = New NotesDocument( maildb )
Set rtitem = New NotesRichTextItem( maildoc, "Body" )
Call rtitem.AppendText ("The following user was deleted by " + session.CommonUserName + ": " + Cstr(doc.FirstName(0)) + " " + doc.LastName(0))
maildoc.Form = "Memo"
maildoc.SendTo = "Recipient"
maildoc.Subject = "Intranet Directory Document Deleted"
Call maildoc.Send( True )
Next
Continue = True
End Sub
provided by Julian Robichaux at nsftools.com.
And here is a sample of what the logging database can look like as a single repository for tracking multiple databases:
Show-n-tell thursday
No comments:
Post a Comment