Domino Code Fragment

Code Name*
Updating the backend NotesDocument in the QueryOpen Event.
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.143.168.172
Description*
When the QueryOpen event is triggered, the Notes document is already loaded into the memory but nothing is displayed on the screen yet. You can take this chance to change the values of some of the fields. For example, you can count how many times a document has been opened (or who opened it) without having to put the document into edit mode.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
The change is in memory only. The front end class NotesUIDocument will not know you have made a change. It will not ask if the document needs to be saved before closing. In fact, if the document is opened in read mode only, no change will be made to the .nsf file. So how do you record your changes? You can 1. Use the QueryClose event to save the changes. The document doesn't have to be in edit mode to make the change, but the user has to have author rights to the document or the save will not execute. 2. Log the information to another database 3. Update a profile document 4. Log to a text file or other data source.
Files/Graphics attachments (if applicable): Code:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim doc As NotesDocument
Dim i as Integer
If Not(Source.IsNewDoc) Then
Set doc = Source.Document
i = doc.NumberOfTimeOpened(0)
doc.NumberOfTimeOpened = i + 1
End If
End Sub