Genii Weblog

Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.

Tue 24 Aug 2004, 11:12 AM
There are a number of questions which come up on the forums over and over, and many of them relate to hide-when formulas.  I recently wrote a post on Writing better hide-when formulas, which has been very popular and is frequently visited and linked to.  I decided to follow that up with a post on hiding a rich text field, since that is also a common question.  I pulled this from a few of the many times I've answered this question, including this one back in 1999.

What is the question?
The question is asked different ways, but the common issues are that the hide-when formula appears not to work at all, or it only hides part of the rich text field.  Sometimes, attachments are shown when the rest of the rich text field isn't.

What is the issue causing the problem?
In my Rich Text 101 - Hide-when formulas and my earlier Rich Text 101 - Paragraphs, I explain that hide-when formulas are attached to or associated with paragraphs, and that since rich text fields contain embedded paragraphs, those can have hide-when formulas which differ from the form.  In particular, it is not uncommon to create a form with a rich text field and a hide-when formula on the field, then later change the hide-when formula.  On documents created prior to the change, the first paragraph is likely to reflect the new hide-when formula because it is the "default" paragraph, but subsequent paragraphs are likely to reflect the older formula.
What is the best solution?
Keeping in mind that there are no perfect solutions, there is one good workaround.  Put the rich text field inside  a section on the form, and add the hide formula to the section.  The best way is to collapse the section, and put the hide-when formula on it directly.  Now, expand the section and make sure there is no hide-when formula on the field inside the section.  This technique will hide attachments and both old and new documents, even if they were created before the change.  It also has the advantage that it does not add any hide-when formulas to the rich text inside, so the rich text can be copied elsewhere and not carry long unwanted hide-when formulas.

What are other solutions and why are they not good?
The most common other solution I see is to use computed subforms which contain the rich text field.  While this seems like a good idea, Notes has so many problems with rich text fields on subforms that you are likely to cause more problems than you solve.  Another solution people suggest is to use a computed field which computes to the real rich text field.  This just doesn't work, both because the computed formula will only work when the document is created, and because computed rich text fields can totally mess up the formatting of the rich text, stripping out tables and otherwise causing major changes you don't want.

Copyright 2004 Genii Software Ltd.