Wed 15 Jan 2020
The tree you are busy hugging has new branches
Fri 20 Dec 2019
Changes coming in the new year
Tue 22 Oct 2019
Domino is used by, you know, actual business people
Rich Text 101 - Hide-when formulas
Tue 1 Jun 2004, 08:40 AMTweet
by Ben Langhinrichs
For years, a frequent topic of discussion on the Notes/Domino technical forums has been hide-when formulas and how they "screw up" rich text fields. I thought it might be worth describing this a bit more fully.
Rich text is more widely use in Notes/Domino than people often understand. Besides rich text fields, rich text is the basis for forms, subforms, pages, image resources, shared fields and more. When a form is rendered, on the screen, on the web, or to a printer, the rich text of the design elements is merged together with the rich text in fields and all the other field data types as well.
Wherever rich text is rendered, a basic building block is the paragraph. (See related posts for more) Paragraph settings determine the margins, tab settings, spacing and such, as well as hide flags and hide-when formulas. In general, paragraphs must begin on a new line, except in the case of a table cell, where each cell starts with a new paragraph, a section, where the content also starts with a new paragraph, and a layer, where the layer content may appear positionally elsewhere, but the content still starts with a paragraph. An important point here is that a field does not start a new paragraph. This is why hide-when formulas and hide flags can't be set differently for two fields on the same row unless they are in different table cells. The flags are actually set on the paragraph in which the field resides.
Hide Formula Implementation
Hide formulas, as mentioned above, work on paragraphs. Whether these paragraphs start on a form or inside a rich text field, the hide-when formula will have the same effect. The confusing aspect of this is that rich text fields have their paragraph settings, or some of them, embedded within the rich text. When a hide-when formula is set on the paragraph containing a rich text field, and then documents are created using that form, the hide-when formulas are included inside the rich text. If the same rich text field is shown on a different form with different hide-when settings, or none at all, or even if the original form is modified to remove the hide-when formula, the existing documents still maintain the formula. A similar issue can be seen with margins if a rich text field is originally created inside a table cell and later the rich text is displayed outside the table cell.
A Partial Fix to Hide-When formulas in Rich Text Fields
There is a special trick you can use when hide-when formulas have been embedded in rich text fields, and you want to change the hide-when formula on the form. Since you can only have one paragraph on a row (as described above, table cells count as separate rows even if they are side by side), you can add a space before the rich text field on the form. The initial paragraph of the character you added takes precedence over the paragraph inside the rich text. This will also "fix" other paragraphs which happen to exactly follow the paragraph definition of the first paragraph, but let's say you indented at some point or changed tab settings or centered something. Those paragraphs will still follow the embedded paragraphs, and therefore still use the hide-when settings that were there before. That is why it is only a partial fix. Nonetheless, it is often enough for cases where no special formatting is likely to have taken place.
To be clear - be careful. You may think you have fixed the whole problem, but you have only fixed a subset. That may be enough for your needs, but you also might be in for a nasty surprise. What's more, those other paragraphs won't get fixed when you edit and save the document either.
More Permanent Fixes
There are tools, native and third party, for fixing the hide-whens, if you need them. If you are using Notes/Domino 6.x or beyond, DXL provides the ability to dump all of the rich text as XML, make modifications to the <pardef> tags to remove the hide-when formulas or reset them to a different value, then re-import the rich text. In R5 and before, or where XML programming is beyond the scope or skill set of a project, our Midas Rich Text LSX will allow you to modify hide-when formulas and other paragraph settings directly.
For information on writing hide-when formulas, see Writing better hide-when formulas.
For information on the implementation of rich text in Notes/Domino, see Rich Text 101 - Rich Text Itself.
For information on paragraphs and paragraph settings, see Rich Text 101 - Paragraphs and Rich Text 101 - Text.
Copyright © 2004 Genii Software Ltd.
What has been said:
163.1. Bob Reichlen (11/12/2004 11:32 AM)
I have many douments (thousands) that were created with a form that originally contained only one rich text field - for attachments. This RT field had hide-when formulas on it. Subsequently we have redesigned the form, eliminated the hide-when formulas and added three new rich text fields for attachments.
The problem now is that the original RT field and one other don't show up when the form in being displayed on Notes (in display or edit mode). I have 3.30 copy of Midas and I'm running on Domino Version 6.03.
I tried using a code example from the Midas Help database to clear the hide-when formulas, but it isn't working. I've included the sample code below. I can see the attachments when I view the docs on the Web. And I know how to cean up the docs one at a time manually. I Save the attachment to my local system while viewing from the Web. I then use a Notes formula to remove the bad fields from a document. Then I open the doc in Notes and re-attach the attachment. But this is certainly impractical for the number of docs I need to fix.
The code I tried is as follows:
' *** Clear all hide attributes from rich text fields in selected documents, ' *** including hide-when formulas, hide from notes/web and hide when
' *** reading/editing/copying
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtitem As New GeniiRTItem
Dim rtchunk As GeniiRTChunk
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument
While Not (doc Is Nothing)
Call rtitem.Connect(db.Server, db.FilePath, doc.NoteID, "Body")
If rtitem.IsConnected Then
Set rtchunk = rtitem.DefineChunk("Everything")
' *** Clear all the hide-when attribute flags
rtchunk.ParagraphStyle = |-HIDE_WEB -HIDE_PREVIEW_READ -HIDE_EDIT
-HIDE_PREVIEW_EDIT -HIDE_PRINT -HIDE_COPY -HIDE_EMBEDDED -HIDE_MOBILE|
' *** Clear all the hide-when formulas
rtchunk.HideFormula = ""
Set doc = collection.GetNextDocument(doc)
163.2. Khader (07/14/2005 04:47 AM)
Notes crashes, quite often, what wil be the cause ?
and how to solve this problem
163.3. Ben Langhinrichs (07/14/2005 04:55 AM)
I'm afraid that is too general a question. Does the crash have to do with hide-when formulas?
163.4. Ahamed (11/09/2009 01:12 PM)
Hi, Your fix to the rich-text hide-when issue (by adding a blank space) helped me. Thank you!
163.5. Joel (02/07/2012 15:35)
Thanks for this. As a newcomer to the world of Lotus Notes this solved my problem without needing to go to a huge level of complexity.