Manage Learn to apply best practices and optimize your operations.

Prevent Fast Deletion From User

Many users don't realize that when they delete a document, there is no way to
get back that document. If the user wants to, you have to explain the problem
to the server administrator and he must then retreive that document from a tape
backup. A real waste of time!
You will have to take three steps to get that solution:

First, you will have to build a new database. This database will contain all
the deleted documents from all the databases you will modify for deletion
preventing.
Second, you will have to modify the ?QueryDocumentDelete? in all the databases
in which you want to implant this solution and insert a new item to know from
which database all the deleted documents came.
Third, create an agent that purges documents after two weeks of deletion and a
button that retreives deleted documents.

Step 1: Create your new database. For the example, I'll name it ?FastDeletion?.
I'll make also a view named ?Deleted Documents? categorized on the new field
name ?FromDatabase?.

Step 2: Modify the ?QueryDocumentDelete? event.

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
Dim Collection As NotesDocumentCollection
Dim Document As NotesDocument
Dim DeletedDoc As NotesDocument

'retreiving all documents that the current NotesUIDatabase event is working
on
Set Collection = Source.Documents
Set Document = Collection.GetFirstDocument
Dim DBDeletion As New NotesDatabase ("", "FastDeletion.nsf")
Dim DateTime As New NotesDateTime (Today)
Dim Item As NotesItem
Do While Not (Document Is Nothing)

Set DeletedDoc = Document.CopyToDatabase (DBDeletion)
'Create a flag to tell the view from where that document has been
proceed to be destroyed
DeletedDoc.FromDatabase = Document.ParentDatabase.FilePath
DeletedDoc.FromServer = Document.ParentDatabase.Server
Set Item = New NotesItem (DeletedDoc, "WhenDeleted", "")
Set Item.DateTimeValue = DateTime
'dont forget this property if you want to be able to use this item in
the search
Item.IsSummary = True
Call DeletedDoc.Save (True, False)
Set Document = Collection.GetNextDocument (Document)

Loop

End Sub

Step 3: Purge and retreive. (Put them in the ?FastDeletion? Database.)

The agent for purge should work every day at 4 am to avoid conflict with the
admin process on the server during the night.

Sub Initialize
Dim Session As New NotesSession
Dim Coll As NotesDocumentCollection
Dim DateTime As New NotesDateTime (Session.CurrentDatabase.Created)


'Adjust date for last 2 weeks
Set Coll = Session.CurrentDatabase.Search ("WhenDeleted < @Adjust
(@Today;0; 0; -14; 0; 0; 0)", DateTime, 0)

'if there is at last one or more documents to purge
If Coll.Count > 0 Then Call Coll.RemoveAll (True)

End Sub

The action for retrieve should be placed in the ?Deleted Documents? view.

Sub Click(Source As Button)
Dim Session As New NotesSession
Dim Coll As NotesDocumentCollection
Dim DocRestore As NotesDocument
Dim Doc As NotesDocument
Dim DB As NotesDatabase

'Get all documents selected by user
Set Coll = Session.CurrentDatabase.UnprocessedDocuments

'if there is no document selected
If Coll.Count = 0 Then End

Set Doc = Coll.GetFirstDocument
Do While Not (Doc Is Nothing)
'Get the Database property
Set DB = Session.GetDatabase (Doc.FromServer (0), Doc.FromDatabase
(0))
'Make the copy and delete the field used for deletion
Set DocRestore = Doc.CopyToDatabase (DB)
Call DocRestore.RemoveItem ("FromServer")
Call DocRestore.RemoveItem ("FromDatabase")
Call DocRestore.RemoveItem ("WhenDeleted")
Call DocRestore.Save (True, False)
Set Doc = Coll.GetNextDocument (Doc)
Loop

Call Coll.RemoveAll (True)
Dim WorkSpace As New NotesUIWorkSpace
Call WorkSpace.ViewRefresh
End Sub

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close