Dazu sagt die KBASE:
Opening document or composing memo based on stationery results in error: 'The document is already locked..'
Problem
In mail files which multiple users have access to, the following error message occurs when a user attempts to edit a draft memo, or create a memo using Personal Stationery:
"The document is already locked by <username>"
For example, User A creates a memo based on a particular Stationery document. When User B attempts to create a memo based on the same stationery the error occurs, indicating that User A has the document locked.
The error can also occur in databases which are not based on a mail template. The issue occurs whether or not the Database Property, "Allow Document Locking" is enabled.
At times the issue will not occur if the first user closes the database or logs out of Notes (either by selecting the F5 key or by a ID lockout set up in the User Preferences).
Note: This same error will occur when creating new documents with an Action or Agent that uses LotusScript to create the document. For more information on this issue see the following document:
"Error: 'The document is already locked...' when using actions or agents to create documents" (#1166480)
Solution
This issue is relative to the use of Soft Locking. Soft Locking goes into effect when a document is opened in Edit mode. In cases where a document is closed while still in Edit mode the document is not unlocked.
An additional scenario also exists. The second scenario is related to the fact that new documents created in the back-end (including User Interface triggered LotusScript code) are assigned a NoteID of 0. When two or more users create such documents, each document they create has a NoteID of 0. The soft locking feature locks documents based on the NoteID; so, even though there are two (or more) different documents, the soft locking feature recognizes only that NoteID 0 is already locked.
The issue relative to soft locking and new back-end documents was reported to Quality Engineering as SPR# KHAN5U4NVZ and was fixed in Domino 6.0.4/6.5.2 and 7.0. The fix resolves a number of scenarios where soft locking errors were encountered, including the one involving the use of Stationery in a mail file. Refer to the following document for scenarios involving LotusScript:
"Error: 'The document is already locked...' when using actions or agents to create documents" (#1166480)
Excerpt from the Lotus Notes and Domino Release 6.0.4 / 6.5.2 MR fix list (available at
http://www.ibm.com/developerworks/lotus):
Database
SPR# KHAN5U4NVZ - This fix prevents a 'not authorized' error that can occur when archiving with compact -a.
In cases where the above fix does not resolve the issue then soft locking can be disabled using a Notes.ini parameter introduced in Notes Domino 6.5.1, 6.0.4 and 7.0.
Excerpt from the Lotus Notes and Domino Release 6.5.1 MR fix list (available at
http://www.ibm.com/developerworks/lotus/):
Editor
SPR# GKAA56ETP6 - Document soft-locking can now be disabled client-side in the editor by setting the ini parameter EDIT_NO_SOFT_LOCKS=1.
To programmatically add the new parameter to a user's Notes.ini:
The LotusScript SetEnvironmentVar method (of the NotesSession class) can be used to set or modify environment variables. To add the parameter to a Notes Client's Notes.ini the following code would need to be executed by the user. It could be placed in a agent, button or the PostOpen event of the database. After executing the code users will need to restart their Notes client in order for the parameter to be applied.
Dim session As New NotesSession
Call session.SetEnvironmentVar( "EDIT_NO_SOFT_LOCKS", "1" , True)
To Avoid the Issue in the Future
Forms other than Stationery:
The issue can be avoided in the future by making sure to switch a saved document from Edit mode back into Read mode before closing it. Forms can easily be redesigned by an application designer to do this. In the case of the Memo form a designer can add the following below existing code in the QueryClose event:
If Not( Source.IsNewDoc ) And Source.EditMode = True Then
Source.EditMode = False
End If
Stationery scenario:
A partial fix can be accomplished by adding LotusScript code to the QueryOpenDocument event of the "(Stationery)" view. This will only resolve the issue if the one creates a memo based on the stationery by opening the stationery document, and composing and sending the memo. It will not resolve the issue in cases where the menu is used: New Memo -> New Memo -> Using Stationery.
Code to add to the "(Stationery)" view's QueryOpenDocument event:
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim docs As NotesDocumentCollection
Dim doc As NotesDocument
Dim newDoc As NotesDocument
If Not (session.GetEnvironmentString("MailStEd") = "2") Then
Set docs = Source.Documents
Set doc = docs.GetFirstDocument
Set newDoc = New NotesDocument (doc.ParentDatabase)
Call doc.CopyAllItems (newDoc)
Call newDoc.RemoveItem ("IsMailStationery")
Call ws.EditDocument (True,newDoc)
Continue = False
End If
Workaround:
If the error occurs while attempting to create a memo based on a Stationery document, then the workaround is to create a copy of the Stationery document and then work with the copy.
For other documents not based on a Stationery document use the following steps to work around the issue:
1. Open the document in Edit mode.
2. Place the document into Read mode (press the CTRL+E keys on the keyboard or select Actions --> Edit from the Notes menu to toggle back to Read mode).
3. Close the document.
In addition to the above workarounds there is the option of enabling document locking and then having the original user, or a user with Manager access, use the Unlock Document action to release it. This methodology has the drawback that additional documents could be locked by users while the property is enabled; and those documents, in turn, would need to be unlocked. To enable document locking for a database select File -> Database -> Properties and select the 'Allow Document Locking' checkbox on the first tab of the InfoBox that pops up. To then unlock a document select it and then select from the menu Actions -> Unlock Document.
The above techniques should also assist the user when attempting to unlock a document in cases where the Notes Client crashed or locked prior to the user unlocking the document. The fact that there is not a specific command or function to unlock Soft Locked documents has been reported to Lotus Software Quality Engineering in SPR MROE5KJT5V.
Supporting Information:
Users can create personal Stationery documents by expanding the Tools folder in the left-hand navigator of the mail file (and the view level) and selecting the Stationery folder. When the Stationery view opens to the right, select the New action button and select "Stationery - Personal".