I have recently had to deal with the frustration of Soft Document Locking on an application I was building which was causing fits for the way it was being designed (and for other legacy applications to be upgraded to ND6).
My scenario was that I was using a document link in the “About” document for the database launch. This document needed to be opened in edit mode because of how I was designing the Navigation in conjunction with Tabbed Tables. Of course once one person opened the document, the document was locked by the soft locking mechanism bult into ND6 (document locking was not enabled on the database).
As this was a non-starter for what I was trying to accomplish, here is how I did a workaround (I could not find one searching here), and would appreciate other people’s thoughts, comments and feedback):
-
Set the database properties to allow document locking.
-
In the PostOpen event (for documents opening by default in Edit Mode) or the PostModeChange Event (for documents to be manually be put into Edit mode), put the following code:
Sub Postopen(Source As Notesuidocument)
Dim doc As NotesDocument
Set doc=source.document
Call doc.RemoveItem( “$Writers” )
Call doc.RemoveItem( “$WritersDate” )
Call doc.Save( True, True )
End sub
NOTE: The following will NOT work:
Sub Postopen(Source As Notesuidocument)
Dim doc As NotesDocument
Set doc=source.document
Call doc.UnLock
Call doc.Save( True, True )
End Sub
So far this has worked like a charm FOR MY SCENARIO and peopbably would not be the best approach for other purposes, such as “real documents” in a workflow. But this does look like it will save me much agony and many headaches. I will keep testing and post again if I find there are problems.
Christopher Byrne, IBM CAAD/CASA
The Cayuga Group, LLC