Manage Learn to apply best practices and optimize your operations.

Hide when formulas for rich text fields

This tip describes the procedure for hiding when formulas for rich text fields.

Once you have created a RichTextField on a form and if you have assigned a Hide-When-Formula to it, then every document gets this Hide-When-Formula as a "fix"-property on this RichTextField.

Lotus tells us here, that this works as it should be. Nevertheless sometimes I have wasted time on this "feature" because the formula have changed during the application running time. The information in the RichTextFields couldn't be displayed with the new formula.

Create an agent which scans all the relevant documents. This agent extracts the text of the desired RichTextField(s) on the document, deletes the Field and recreates it. Finally the extracted text is written into the "new" field.

Also for included attachments this way can help to have access on the files. Here you have to use the GetEmbeddedObject()-Method of the RichTextField, extract the files on disk and re-attach them on the "new" field.

There are restrictions on the functionality with the code published below. Pictures or documents which have been created as objects in the RichTextField can't be restored. Formatted Text with colors and different shapes or fonts will lose it's attributes and will be restored as plain text. But sometimes this one is better than telling your users or customers that they will have to re-type everything.

And: if someone can expand the functionality of this code, so that there aren't any restrictions - go on and publish it on this site.

Here's the code for the Agent. The code is designed to regain access only for the text inside a RichTextField

Option Public

Dim s As NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtf As NotesRichTextItem
Dim rts As NotesRichTextStyle

Sub Initialize()
 Dim Search As String
 Dim rtfText As String
 Dim fldList As Variant
 Set s = New NotesSession
 Set db = s.CurrentDatabase
 Search = |SELECT Form="frmFormName"|
 Set col = db.Search(Search, Nothing, 0)
 If col.Count>0 Then
  fldList = Evaluate(|"rtfField1":"rtfField2"|)
  Call SetRTS()
 Set doc = col.GetFirstDocument()
 While Not(doc Is Nothing)
  Forall f In fldList
   Set rtf = doc.GetFirstItem(f)
   rtfText = rtf.GetFormattedText(False, 0) 'extract text
   ' >> Here goes the code for extracting attachments <<
   Call doc.RemoveItem(f)
   Set rtf = New NotesRichTextItem(doc, f)
   Call rtf.AppendStyle(rts)
   Call rtf.AppendText(rtfText)
   ' >> Here goes the code for re-attaching the files >>
   Call doc.Save(Treu, False, False)
  End Forall
  Set doc = col.GetNextDocument(doc)
 End If
End Sub

Sub SetRTS()
 Set rts = s.CreateRichTextStyle
 rts.Bold = False
 rts.Italic= False
 rts.FontSize = 9
 rts.NotesColor = 0 'black
End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...