Locking Document
Locking Document
(OP)
I have a document that can be opened and edited. I need help on how to lock this document if another users is updating or editing the document so that 2 users can not be in edit mode on the same document at the same time.
Thanks In Advance
BH2
Thanks In Advance
BH2
RE: Locking Document
flag = notesDocument.Save( force, createResponse [ , markRead ])
Parameters
force
Boolean. If True, the document is saved even if someone else edits and saves the document while the script is running. The last version of the document that was saved wins; the earlier version is discarded.
If False, and someone else edits the document while the script is running, the createResponse argument determines what happens.
createResponse
Boolean. If True, the current document becomes a response to the original document (this is what the replicator does when there's a replication conflict). If False, the save is canceled. If the force parameter is True, the createResponse parameter has no effect.
RE: Locking Document
The best method I've found is to have your main doc create a lockdoc when it is put into edit mode. Prior to creating the lockdoc, in querymodechange, check for the existance of a lockdoc for the doc being edited (described below). If it exists, pop up a message saying who is editing the doc, when did they start, etc. and cancel change to edit mode.
These lockdocs are stored in a sorted view by doc ID of the DOC BEING EDITED or some other unique feature. The lock doc should also capture the user's name, time lockdoc went into edit and other relevant info.
When the user is done editing (eg; close event), have your script access the lockdoc view and delete the lockdoc. If user's don't have delete permission in ACL, change the lockdoc form name to frmDelete or something like that and then run a daily agent to clean up all docs with form=frmDelete.
Another method is using a 'BeingEdited' field on the doc being edited but this does not work that well because you have to save the doc as soon as you set BeingEdited to yes. Then if the user decides not to save the doc, you have to restore all field values and save it again. Lots of unnecessary saves which messes up history fields, etc.
Hope this helps
YakUp
RE: Locking Document
They have a professional solution for document locking covering Notes/Web clients and server based agents.
Works fine in our environment.
Hope this will help.