SNTT : Validating a Notes Client Rich text field

Rather than testing the field on the Notes Document object (my reflex habit) , test a rich text field in the Notes UI Document object, because until the document has been saved, the rich text field either does not yet exit (if a new document) or hasn’t been updated.

The assumption in the code below is that Source is a NotesUiDocument object, the “title” field is a editable text field and “body” is a editable rich text field, and the whole thing is part of the forms query save event.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sub Querysave(Source As Notesuidocument, Continue As Variant)

  If Source.Document.Title(0) = "" Then
     Msgbox "Please add the Title value.", 0 + 16, "Validation Error"
     Source.GotoField("Title")
     Continue = False
     Exit sub
  End If

  If Source.FieldGetText( "body" ) = "" Then
     Msgbox "Please add the the Body value.", 0 + 16, "Validation Error"
     Call Source.GotoField( "body" )
     Continue = False
     Exit sub
  End If

end sub

Leave a Reply