Is there a way of triggering some LotusScript when a document is exited using the Esc button. Presumably the Queryclose event is not triggered when pressing the Esc button to close it?
Subject: Many thanks Guys
Subject: Maybe this will help.
There are times when you do not want a user to be able to close a form by choosing escape or selecting “file/close” from the menu.
In my case I wanted the response document to update totals on the main document before exiting.
This shows one way to force a user to close a form by taking an action you specify. (for example, Clicking an “Update and exit” button.)
My form is in editmode when the user opens it.
If your form is not in edit mode initially, you may want to move the “postopen” code to the “postmodechange” event.
On the form I have a hidden editable field called “EscapeCheck” (Could actually have any name)
In the postopen event of the form as soon as the form opens, I set this editable field “EscapeCheck” to the value “NoExit”:
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Call Source.FieldSetText ("EscapeCheck","NoExit")
The Input Validation event for the EscapeCheck field is coded as…
@If(EscapeCheck=“NoExit”;@Failure(“Please click 'Update and Exit' to Close”);@Success)
In my case, this validation is only done when the document is being saved.
If, in your case, you “refresh” the document some time before exiting you may need to add an @IsDocBeingSaved condition to this formula.
When the user tries to escape from the form, he gets the “Please click ‘Update and Exit’ to close” message and the form does not close.
Final piece is to include the following code in the click event of an “Update and Exit” button.
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc= workspace.CurrentDocument
uidoc.editmode = True
Call uidoc.FieldSetText ("EscapeCheck","OK")
Call uidoc.Save
This sets the EscapeCheck field to a value other than NoExit and allows the form to close.
(You can add any other updating code your need to this button.)
Subject: Closing doc using Esc triggers QueryClose event