Domino 9 und frühere Versionen > ND6: Entwicklung

Entsperren von Dokumenten

<< < (2/3) > >>

Glombi:
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".

robertpp:
Also ich denke die Funktion kann man derzeit noch vergessen. Ich programmiere das auch selber.

Hab dazu auch gerade einen guten Eintrag bei der Hand:

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci765142,00.html

Glombi:
Die Zeilen

docBackend.Lock=nnUserName.Common
ersetzen durch
call docBackend.ReplaceItemValue( "Lock", nnUserName.Common )

und

docBackend.Lock=""
ersetzen durch
call docBackend.ReplaceItemValue( "Lock" , "" )

denn "Lock" ist ab R6 reserviert.

Andreas

buzzy666:
Also ich werd's vielleicht einfach mal mit einem

If doc.LockHolders(0) = s1.UserName Then      
   Call doc.UnLock()      
End If   

auf dem QueryClose-Event versuchen...vielleicht bringt das ja schon was.
Ausserdem hab ich meine Admins mal angespitzt, sich bzgl. Softlocking schlau zu machen...

Greets,
Buzzy

robertpp:
Ja ich hab das Script auch etwas umgebaut:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
   If (Source.IsNewDoc) Then
      Exit Sub
   End If
   Dim varLock As Variant
   Dim s As New NotesSession
   Dim doc As NotesDocument
   Dim UserName As New NotesName(s.UserName)   
   Set doc=Source.Document
   varLock=doc.GetItemValue("LockEdit")
   If (varLock(0) <> "") And Source.EditMode Then
      Msgbox ("Document is currently locked by "+varLock(0)+". A read-only copy will be opened for your use.")
      Exit Sub
   End If
   doc.LockEdit= UserName.Common
   doc.LockEditTime = Now
   Call doc.Save(True,False)
End Sub

Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
   Dim item As NotesItem
   Dim dos As NotesDocument
   Set doc = Source.Document
   Set item = doc.GetFirstItem("LockEdit")
   If ( Not item Is Nothing ) Then
      If doc.LockEdit(0) <> "" Then
         Dim s As New NotesSession
         Dim UserName As New NotesName(s.UserName)
         If (Strcomp(UserName.Common,doc.LockEdit(0),5)=0) Then
            continue=True
         Else
            Msgbox("Sorry, you are in read-only mode ! This operation cannot be performed. This document is currently used by "+Source.FieldGetText("LockEdit"))
            continue=False
         End If
      End If
   End If
End Sub

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
   Dim s As New NotesSession
   Dim doc As NotesDocument
   Dim UserName As New NotesName(s.UserName)
   Set doc=Source.Document   
   Set item = doc.GetFirstItem( "LockEdit" )
   If ( Not item Is Nothing ) Then
      If (Strcomp(UserName.Common,doc.LockEdit(0),5)=0) Then
         Call doc.RemoveItem("LockEdit")
         Call doc.RemoveItem("LockEditTime")
         Call doc.Save(True, True)
      End If      
   End If
End Sub

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln