Hide 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

This was first published in August 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.