API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
Programmatically Hiding A Rich Text Field
Have you ever wanted to apply a hide-when formula to a rich text field on a form? You would think that you could just apply it and it would work. However, it doesn't quite work that way. Rich text fields, by their nature, have paragraphs that have hide-when formulas. So, technically, a user could come in and erase the hide-when formula or modify it to fit their own needs. Putting a hide-when formula around a rich text field on a form actually creates a default hide-when formula on the first paragraph of the rich text field for all new documents. The user can modify this value if they choose. Once the document is saved, the hide-when formulas inside the paragraphs of the rich text field are saved along with the document. So if you update the hide-when formula on the form, it will not have any affect on documents that already exist.

In order to truly have a hide formula on a form applied to a rich text field (or a rich text lite field in ND6), you need to get a little tricky. First, put your rich text field into a subform. If there's anything else around the rich text field that has the same hide formula (like a label for the field), put that in the subform as well. On the subform, there should not be any hide formulas. Everything should be visible all the time. Then, on your form, use a computed subform. The formula for the computed subform should compute the time to show the subform. To compute the time to hide the subform, use an empty string. For example, if you only want to show the rich text field to administrators, you could use this value for the computed subform:

@If(@IsMember("[Admin]"; @UserRoles); "Rich Text Field"; "")

Doing things this way truly does work - the subform will only be brought in if the formula tells it to be brought it. However, keep in mind that computed subforms are only computed when the document is opened - so pressing F9 will not be able to switch whether the rich text field is shown or hidden. It will take a close and re-open of the document. As long as you can live with that limitation, this technique does the trick.