Richtext

Hello everyone,I have a rich text field, how I can validate for the Rich Text field says it has an attached file.

If the field does NOT have an attachment, as a document.doc, or document.xls or document.pdf.

Then tell me validation

that you have to attach a document.

Thanks, I hope your help.

Subject: You could use DXL to check the content in a rich text field really well. Try to search for DXL and attachment and richtext

Subject: My method

My method is for a notes client and not for the web.

In my case I had 6 fields for 6 different type of attachments. I had to test for missing documentation using their business logic. I changed the fields to RichTextLite and set the fields only to support attachments. In the querysave I used a function shown below to test whether the field is null or not that set flag fields for each field. That way I can use show status in a view if I needed too. The function was not mine and I found it 8 years ago on the web and didn’t note the author at the time. Apologies to that person.

(code snip to detect rtf attachment) rtfield is the name of the field

Function IsRTFNull(rtfield As String) As Integer

%REM

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.

%END REM

On Error Goto Errhandle

Dim currentfield As Variant

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument



Call uidoc.ExpandAllSections 

'This is only needed if your field is in a section that may be closed when this executes

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

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

	Exit Function

Case Else

'For any other error, force the same error to cause LotusScript to do the error handling

Error Err

End Select

Exit Function

'…end code