Genii Weblog

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

Tue 1 Jun 2004, 08:40 AM
Rich Text 101 logo
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.

Related Posts
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.