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


(Options)
Option Public

(Declarations)
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)
  
        Wend
 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
This Content Component encountered an error

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close