Getting the back-end document to save correctly

Hi guys,

Hoping someone has an answer to this problem:

scenario: I built my own locking system that allows only a single person to edit a document. I do this by placing a field called hasEditor in the form which contains the name of the user editing the document. When a user opens the document and the hasEditor field already contains a name, i just give that user read access, no edit, until the user editing the document releases or closes the document. Up to that point, i have no problem, everything works.

But this is where my problem starts, here’s the code:

Sub Queryclose(Source As Notesuidocument, Continue As Variant)

If Not(uidoc.IsNewDoc) Then

	If uidoc.EditMode Then

		Dim db As NotesDatabase

		Set db=ses.CurrentDatabase

		Dim tdoc As NotesDocument

		

		Set tdoc=db.GetDocumentByUNID(doc.UniversalID)

		tdoc.hasEditor=""

		Call tdoc.Save(True,False)

	End If

End If

End Sub

the objective of this code is that when user the user exits/closes the form, hasEditor filled is set to “”. Supposedly this code should work even if the user made changes to the form and did not save it. Unfortunately, it saves the changes of the user in the form even if the user chose not to save it in the saveOptions dialogue box. That is why i did not get the value of tdoc using uidoc.document but i used GetDocumentByUNID to get it. Because i know with this operation, I can get the back-end document and change only the hasEditor field, even if the user made changes on the form and its changes are not reflected in the back-end. Unfortunately this does not work. The only thing i want is to get the back-end without the changes.

Thanks in advance.

Subject: Getting the back-end document to save correctly

Thank you guys for your help…

well the solution for this problem was given to my by a fellow programmer. She told me that to get the back end doc without the changes is to make a view, put in the first column of that view the UniversalID of all the documents, and from there use getDocumentByKey. it worked…

Thank you guys again for your help

Subject: Getting the back-end document to save correctly

Hi Andres,

uidoc is not declared in this Sub!

May be you use Source instead -

Hope this will help

Subject: You have found the problem.

My best solution to that problem is to create a “shadow” document for every real document in the db and store your editing flag there.