Soft Deletions and LotusScript

Friday, February 26, 2010 by Jeff Tujetsch

Trying to locate a soft deletion in LotusScript can be an information management challenge itself. Before soft deletions, it was easy to navigate the $Trash folder and find the deletions. However, soft deletions add another level of complexity. If you have the UNID of a message and try to access it when it has been soft-deleted, an error will be thrown stating that the UNID was invalid. This is actually the same error you would receive if the message was hard-deleted and no longer existed.

However, since the UNID is not viable for finding a soft-deleted message, there is a way to locate the soft-deleted message. The NoteID property remains accessible for both soft-deleted messages and those messages that are hard-deleted, but whose deletion stub still exists (typically, for 120 days after the message is hard-deleted). This allows you to use the 'GetDocumentByID' method within the NotesDatabase class and use the NoteID to locate the message. If the 4270 error is thrown, neither the message, soft-deletion or deletion stub exists. If an error is not thrown, that doesn't mean that you have all of the information that you need. You still have more work to do. Here are the four scenarios.

1. If the NotesDocument is properly instantiated, then you need to check the IsDeleted property. If the IsDeleted property returns False, you have located an 'active' message. If the IsDeleted property returns True, you have located a soft-deleted message.

2. If the NotesDocument is not instantiated (Doc is Nothing), you have located the deletion stub for the message.

3. If the 4270 error is thrown, the message and its deletion stub, no longer exist.

If have included the code to display the four possible scenarios below:

On Error Goto TrapError

Dim CurrentDB As NotesDatabase
Dim Doc As NotesDocument
Dim InvalidNoteID As Integer
Dim Session As New NotesSession

Set CurrentDB = Session.CurrentDatabase

InvalidNoteID = 0

Set Doc = CurrentDB.GetDocumentByID ("xxxxxxxx")

If InvalidNoteID = 0 Then
   If Doc Is Nothing Then
      Print "Deletion stub"
   Elseif Doc.IsDeleted Then
      Print "Soft deletion"
   Else
      Print "Active message"
   End If
Else
   Print "No message"
End If

Exit Sub

TrapError:

Select Case Err
   Case 4270
      InvalidNoteID = 1
      Resume Next
   Case Else
      Print Error + " (" + Cstr (Err) + " )  at line " + Cstr (Erl)
      End
End Select


I hope that this helps with understanding how to access soft-deletions, deletion stubs and better understand this email data storage issue.

Comments for Soft Deletions and LotusScript

Leave a comment





Captcha