Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking Document

Status
Not open for further replies.

BlackHawk2

Technical User
Jan 29, 2002
124
US
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
 
hey! here is the "Help" document info on notesdocument.save (save method in NotesDocument Class) that allows you to not save if it's being edited. Good luck!

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.
 
I'm doing this form home so I can't give you any specific code examples but here's the general idea.

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
 
Try
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top