Inconsistent behaviour with uidoc.close

I know this has been asked before, but there doesn’t seem to be a definitive answer… and my problem has a slight twist. I have a holiday database where only the [HR] role should be able to edit a certain form. To stop the users tweaking their own I have some Lotusscript code (below)… I have placed this code in both the postopen event (to catch those who enter via r-clicking “edit” from the view), and in the postmodechange event (to catch those who switch from read to edit mode).

The code works fine in the postopen event.

But in the postmodechange event, it doesn’t exit the document cleanly, but asks the user whether he wants to save.

Why?

How can I make it exit without asking?

I don’t have a saveoptions field btw

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Dim doc As NotesDocument

Set doc = uidoc.Document



roles = db.QueryAccessRoles(session.UserName)

If roles(0) = "" And source.EditMode=True Then 

	Msgbox "You are not allowed to edit this - please contact HR"

	Msgbox "HR have been informed of this attempt"

	Call doc.AppendItemValue( "Subject","HolReqs - Attempt to modify holiday entitlment")

	Call doc.Send(True,"Jo Wootten")

	Call uidoc.Close(True)

End If

Subject: Inconsistent behaviour with uidoc.close

You don’t need a SaveOptions field in order to set the value. But the real question is why are users able to edit the document in the first place? Don’t depend on event code for security – any reasonably knowledgeable user can get around that easily – without even opening the document.

Subject: Inconsistent behaviour with uidoc.close

You need a SaveOptions field, set to “1”, to force the document to be saved (with your new tracking information) as the UIDoc is closed.

You should also consider removing the SaveOptions field when the document is opened in Edit Mode, so that it does not effect HR’s use of the form.

Warning : What you are doing will not prevent the user from modifying your documents through an agent, as that kind of modification does not use the form, and so your tests are bypassed.

A better method would be to give users Author access instead of Editor access, give HR folks an ACL role, and add that role to the document in an Authors field. Then you are using the built-in Notes security, which cannot be bypassed.

Subject: RE: Inconsistent behaviour with uidoc.close

I needed the SaveOptions field to be present on the form, rather than create the field in the doc from LS independently.

Like many Notes anomalies it is still a mystery why it behaved differently in one event rather than another… but I don’t care anymore coz my immediate problem is resolved !

Thanks chaps!