Deleting Documents

The company which I'm working wanted to delete the documents created using
certain forms and to some users. The users may have access from author to
manager. One way I can do is to write a script in database delete, post delete
and undelete event. But I wanted to simplify the process and to give more
flexibility. I wanted programmatic access for deleting and recovering documents
by user without developer's or administrators intervention. I came up with the
following method and hope it helps you all.
Follow the steps to understand deletion, permanent removal from database and
recovery from accidental deletion.


1. Create a button in view call it as "Delete" and enter the following script
in the click event. All the deleted documents are moved to a Folder called
"DeleteFolder". So, create a folder by name "DeleteFolder" and give access to
authorised people to see the deleted documents and recovery options for
accidental delete.

Sub Click(Source As Button)
Dim oUiWs As New NotesUiWorkspace
Dim oSession As New notessession
Dim oDb As NotesDatabase
Dim oDc As NotesDocumentCollection
Dim oDoc As NotesDocument

Set oDb = oSession.CurrentDatabase
Set oDc = oDb.UnProcessedDocuments
i = 1
If (Not oDc Is Nothing) Then
If oDc.Count > 0 Then
Set oDoc = oDc.GetNthDocument(i)
Do While (Not oDoc Is Nothing)
oDoc.Fc_cDeleteDoc = "1"
oDoc.Fc_tDeleteDate = Now
Call oDoc.Save(True,False)
Call oDoc.PutInFolder("DeleteFolder" )
i = i + 1
Set oDoc = oDc.GetNthDocument(i)
Loop
End If
End If
Call oUiWs.ViewRefresh
End Sub

2. In your view, you got to add this selection criteria.
Select "YourSelectionCriteria" and Fc_cDeleteDoc != "1"

3. Create a scheduled agent(runs daily) to remove the document permanently from
the database when the deleted document is older than let's say 7 days. You can
check with the Fc_cDeleteDate field.

4. To recover from accidental delete, create a button in "DeleteFolder" called
"Recover" and enter the following script.

Sub Click(Source As Button)
Dim oUiWs As New NotesUiWorkspace
Dim oSession As New notessession
Dim oDb As NotesDatabase
Dim oDc As NotesDocumentCollection
Dim oDoc As NotesDocument

Set oDb = oSession.CurrentDatabase
Set oDc = oDb.UnProcessedDocuments
i = 1
If (Not oDc Is Nothing) Then
If oDc.Count > 0 Then
Set oDoc = oDc.GetNthDocument(i)
Do While (Not oDoc Is Nothing)
oDoc.Fc_cDeleteDoc = ""
oDoc.Fc_tDeleteDate = ""
Call oDoc.Save(True,False)
Call oDoc.RemoveFromFolder("DeleteFolder" )
i = i + 1
Set oDoc = oDc.GetNthDocument(i)
Loop
End If
End If
Call oUiWs.ViewRefresh
End Sub


Following are the few advantages when you use this method to delete and recover
the documents

a. Option to delete documents created using specific forms - in your view
include the delete button to delete the documents
2. Permission for selected user to delete the document - set the names/roles in
hide/when property of Delete button
3. Don't want to write long scripts in database delete and undelete event - you
can put the scripts in "Delete" and "Recover" button to a script library so
that you don't have to write the same script in each and every view.
4. Want to recover accidental deletion - All the deleted documents will be
moved to "DeleteFolder" where you've an option to recover the documents
5. Option for deleting documents irrespective of user access rights - by this
method, user having author or manager access can delete the document. but using
readers and authors field you can restrict this access.
This was first published in November 2000

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close