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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock a Notes Document, so noone else may modify it

Status
Not open for further replies.

MoGryph

Programmer
Nov 1, 2000
99
US
I've been beating my head against a wall trying to figure out how to lock a document, so only one person can modify it at any one time.

I'm not useing any replicas, so I don't have to worry about a replica copy being modified.

I did come up with a way to lock the doc. But there's a hitch to it - my method doesn't give them any way of canceling changes!

Here's what I did- in the QueryModeChange, I check to see if they're currently in Read mode, and if they are (I know they're querying to enter Edit Mode), I set a flag in the NotesDocument, and save it.

On the other-hand, if the flag's already set by someone else, I set Continue to false so that they can't enter edit mode.

In the QueryClose event, I delete the flag.

This is fine. But the hairy part comes when a user wants to cancel any changes they made. I can't delete the flag in the document, and save the document, without saving the changes that were made to the NotesUIDocument. The SaveOptions field has no relivance if I perform a save on the NotesDocument itself, and even if it did, I wouldn't want it to NOT save the change of the flag.

The only possiblity I can think of for reverting back to the original values is to create a 2 element array in the General Declarations, enumerate through the NotesItems in the document, and store all Names and Values- then, on a Cancel, set all items to the values I stored in the arrays.

I can't find a single property anywhere, for NotesDocuments, that says whether or not it's opened by someone else. If I could, I could avoid this stupid flag in the first place.

Is there a simple solution, so that I don't have to write all the code for enumerating through the document? Can I cancel, or Undo changes to each Item in the UIDoc?

Thanks

-MoGryph
[8O)
 
Here's a suggestion, no claims as to effectiveness though.
Move you flag to a hidden field and set it when the doc goes into edit mode. Check for the flag on any Open of the documents. Clear the flag on the close event. If you only check during the Doc(open) you don't have to worry about canceling changes. Gamesman
jhughes@barbhosp.com
MT(ASCP), MCP, CIW, CNA
 
I can't seem to clear the flag on the close event, because clearing it requires me to re-save the document, with the flag cleared. Thus, saving any of the changes that the user's trying to Cancel.

I did find a work around, though it's not elegant, and it's not what I wanted. I'm having the user click a button in the view- a "Check-Out" and "Check-In". To edit a document, the user must click "Check-Out" first, which takes care of setting the flag. Then, they "own" it. They can then Open it, Edit it, make changes, and cancel changes all they want. When they're done with all changes and are satisfied, they go back to the main view, and click "Check-In", releasing it to the rest of the document pool.

I don't like this solution, but it seems to be the only one available. I'm still hoping someone might come up with an answer.

-MoGryph
[8O)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top