Genii Weblog

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

Wed 15 Dec 2004, 12:31 PM
It is always surprising to me how I learn new things about Notes every day, given that I have been developing with Notes for about ten years (is that possible?).  Here is a tip about something I did know, and assumed others did as well, but obviously not all do.

The question
Shlomo Beth Nahrin posed this question in the Notes 6 forum:
I want to hide with buttons a table with two rows.
When the user clicks the button1, hide row1, and clicks button2, hide row2.
Sure it's easy, with creating a field and use the contents of that field in the hide when formula.

But how can I solve it in readmode. I don't want to create an environment varible or any technical documents in the backend.

Is there a possibility with using javascript with pass-thru html ?

The answer given
Pretty straightforward question, but two respected developers and frequent forum question-answerers, Stan Rogers and Graham Richards, wrote back that it wasn't possible.  Rather, Stan seemed to indicate it wasn't possible, and Graham came right out and said:
If you are talking about the Notes Client, this won't work in read mode - Notes will only "process" things like hide-whens once as the document is opened. You can't change the display of the document while it's open.  (I can't offer help if this is for the web)

The correct answer (or "what Stan and Graham learned today")
But they are wrong.  One of the odd tidbits I've picked up over time is that you can modify the front end document and act on those changes in read mode.  I built a really slick demo for the Partner Forum with a whole questionaire that works that way, including allowing you to answer questions and totalling your score, all in read mode and not ever changing the document on disk.  But on to the solution.  Simply make a button or hotspot or form action with the formula:

FIELD MyControl := "Yes";

and another with the formula 

FIELD MyControl := "";

and then use hide-when formulas in the table so that the first row has the hide formula:

MyControl = "Yes"

and the second has the hide-when formula:

MyControl <> "Yes"

and then you can switch which one shows in read mode.  Note that if you run this in edit mode, it will save the last value set, but in read mode it won't.  There doesn't even need to be a MyControl variable on the form, unless you want to set a default value. I usually use a default value of "", since that will work if the field doesn't exist at all.  I posted a working demo in the forum so you can go try it out for yourself.

The additional information (or "what I learned today")
And lest you think I am smug, I learned something new as well.  I thought this technique would only work in the Notes client, but as you will see in the demo, it works from the web as well.  I never knew that, so Stan, Graham and I all learned something new today.  I can't wait to find out what I will learn tomorrow.

Copyright 2004 Genii Software Ltd.