Manage Learn to apply best practices and optimize your operations.

Real And Secure Record-Lock

There are a lot of possibilities to make a record lock. But the most
application are making changes in the document or the user can go around the
checkings. Especially opening the document in edit mode, so the querymodechange
doesn?t effect.

This is a way to prevent conflict-documents. When a user tries to edit a
document, that is even beein edited by another user. He becomes a message, that
it?s not possible because a the user X is editing the document.


First of all, create a hidden-view named "LockedDoc". With selection formular
Form = "LockDoc".
First Column Formula "LockDoc"
Second Column Formula "CreatedBy" To
Prevent opening the doc in editmode:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant,
Continue As Variant)

If source.isnewdoc Then Exit Sub


If source.editmode Then
Msgbox "Document can?t be open in editmode" & Chr(10) &_
"Please open the document in readmode and then edit the document !"
continue = False
Else
Print "Document in readmode!"

End If


Check Document Editing Status

Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
Dim s As New notessession
Dim db As notesdatabase
Dim ws As notesuiworkspace
Dim newdoc As notesuidocument
Dim doc As notesdocument
Dim destnote As notesdocument
Dim destview As notesview

Set db = s.currentdatabase
Set ws = New notesuiworkspace
Set uidoc = ws.currentdocument
Set doc = uidoc.document

unid$ = doc.UniversalID
Set destview = db.getview("LockedDocs")
Set destnote = destview.Getdocumentbykey(unid$, True)

If destnote Is Nothing Then
Set lockdoc = New notesdocument(db)
lockdoc.Form = "LockDoc"
lockdoc.LockDoc = unid$
lockdoc.CreatedBy = s.commonusername
lockdoc.save True,False
Print "Dokument f?r andere Benutzer gesperrt !"
Else
lockedby = destnote.getitemvalue("CreatedBy")
Messagebox "Document can?t be edited. "_
& Chr(10) & Chr(10) & "At the moment this doc is editing by " &
lockedby(0) & "." _
&Chr(10) &Chr(10) & "Please try again later !"
Continue = False
End If



End Sub


End Sub


To Lock newly saved documents:


Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim session As New notessession
Dim db As notesdatabase
Set db = session.currentdatabase



If source.isnewdoc Then
Dim destview As notesview

unid$ = doc.UniversalID
Set destview = db.getview("DocLock")


Set lockdoc = New notesdocument(db)
lockdoc.Form = "LockDock"
lockdoc.DocLock = unid$
lockdoc.CreatedBy = session.commonusername
lockdoc.save True,False
Print "Document clodes for other user "

End If


End Sub


Sub Queryclose(Source As Notesuidocument, Continue As Variant)
Dim s As New notessession
Dim ws As New notesuiworkspace
Dim db As notesdatabase
Dim uidoc As notesuidocument


Dim doc As notesdocument
Dim destnote As notesdocument
Dim destview As notesview

Set db = s.currentdatabase
Set uidoc = ws.currentdocument
Set doc = uidoc.document

If uidoc.editmode Then
Print "Document enlocked"
Else
Print "Document in read-mode"
Exit Sub
End If

Continue = True

unid$ = doc.UniversalID

Set destview = db.getview("LockedDocs")
Set destnote = destview.getdocumentbykey(unid$, True)

If destnote Is Nothing Then
Exit Sub
Else
destnote.remove (True)
End If



End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close