Domino Code Fragment

Code Name*
Check RichText Field for NULL
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.217.228.35
Description*
When in Edit mode checks RichText Field for NULL.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
DOcument must be in edit mode !
Files/Graphics attachments (if applicable): Code:


This checks the body field on a form to see if it is empty.

Sub Click(Source As Button)
Call IsRTFNull("body")
End Sub



Function IsRTFNull(rtfield As String) As Integer

'This function tests a Rich Text field to see whether or not it is null. It returns TRUE if the field is null, and
'returns FALSE if the field is not null. It works even if the rich text field contains a file attachment,
'doclink, or OLE object but does not contain any text.

On Error Goto Errhandle

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument

'Store the name of the field that currently has focus. Note: if this function is being called from a form button,
'currentfield will be null (because the button has the focus, and not a field). If this function is called
'from an action button, and if the cursor is in a field, then currentfield will correctly store the name
'of the field that has focus.

currentfield = uidoc.CurrentField
Call uidoc.GotoField(rtfield)
Call uidoc.SelectAll

'The next line will generate a 4407 error message if the Rich Text Field is null


Call uidoc.DeselectAll

'Return the cursor the the field that had focus before this function ran. If the currentfield variable is null (because a button
'or hotspot had focus, then the cursor will actually wind up getting left in the rich text field.

If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If

IsRTFNull = False
Exit Function

Errhandle:
Select Case Err
Case 4407

'The DeselectAll line generated an error message, indicating that the rich text field does not contain anything
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = True
Messagebox "Rich Text is Null"
Exit Function
Case Else
'For any other error, force the same error to cause LotusScript to do the error handling
' Messagebox"Si è verificato un errore nel campo "+rtfield+" di tipo "+Str$(Err)
Error Err
End Select

End Function