Examples: Onselect event

This Onselect event checks a newly selected document and issues an alert if it has been modified since the date it was created. The global variable lastCaretID is used to determine if the document is newly selected.

REM Globals
Dim lastCaretID As Variant
lastCaretID = "000"
Sub Onselect(Source As Notesuiview)
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Set db = session.CurrentDatabase 
    caretNoteID$ = Source.CaretNoteID
    If lastCaretID <> caretNoteID$ Then   ' we only process if the highlighted row has changed
        lastCaretID = caretNoteID$
        noteID$ = "NT00000" + caretNoteID$
        Set doc = db.GetDocumentByID( caretNoteID$ )
        moddate$ = Strleft(doc.LastModified, " ") ' we only care about the date
        createdate$ = Strleft(doc.Created, " ")
        If moddate$ > createdate$ Then 
            Messagebox "This document has been modified since it was created",, _
            "Modification alert"
        End If
    End If
End Sub