About Duffbert...

Duffbert's Random Musings is a blog where I talk about whatever happens to be running through my head at any given moment... I'm Thomas Duff, and you can find out more about me here...

Email Me!

Search This Site!

Custom Search

I'm published!

Co-author of the book IBM Lotus Sametime 8 Essentials: A User's Guide
SametimeBookCoverImage.jpg

Purchase on Amazon

Co-author of the book IBM Sametime 8.5.2 Administration Guide
SametimeAdminBookCoverImage.jpg

Purchase on Amazon

MiscLinks

Visitor Count...



View My Stats

« Memo to phishers... | Main| Whoo-hoo! Lotusphere sessions are posted, and Joe and I have an official number! »

How to Check for a Deletion Stub Using LotusScript

Category Software Development

This gem from the KnowledgeBase caught my attention the other day.  Since I don't often design by storing the UNID of one document in another document, I don't think I've ever been bitten by this.  But it's not an intuitive thing...  You think that if the document is deleted, it's no longer there.  So read on and be warned...  :-)

------------------------------

How to Check for a Deletion Stub Using LotusScript

Document Number:   1085749

Problem
You have a UNID for DocumentA that is stored in DocumentB. Now DocumentA is Deleted.  If in an agent or event you use the UNID stored in DocumentB to retrieve DocumentA using the Doc = DB.Getdocumentbyunid(UNID), you do not get an error.  If you continue to process the using Doc you will probably want to generate an error similar to the following:

If you use this code stub you can generate errors.

Set Doc = DB.Getdocumentbyunid(UNID)
If Not(Doc is Nothing) Then
     .... you think that you have a valid document but it could be a deletion stub
End

Content
The solution is to test for BOTH Doc is Nothing and Doc.Size <> 0.  Here is a sample function:

Function IsDocThere(TestDoc As NotesDocument) As Integer
        IsDocThere = False
        If TestDoc Is Nothing Then Exit Function
        If TestDoc.Size = 0 Then
                Set TestDoc = Nothing
                Exit Function
        End If
        IsDocThere = True
End Function

You can just call this from your code with this.  Upon return, if there is a deletion stub, the Doc is set to nothing so that it does not interfere with tests, and returns False regardless of whether it is a deletion stub or a non-existing document.

If IsDocThere(Doc) Then
      ........ Do Some stuff with document
Else
      ......... Process error if necessary
End If

Comments

Gravatar Image1 - Holy crap. I have some code to go patch!

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Want to support this blog or just say thanks?

When you shop Amazon, start your shopping experience here.

When you do that, all your purchases during that session earn me an affiliate commission via the Amazon Affiliate program. You don't have to buy the book I linked you to (although I wouldn't complain!). Simply use that as your starting point.

Thanks!

Thomas "Duffbert" Duff

Ads of Relevance...