I have a form with one field, which is an editable dialog list. The contents of the list are unimportant, except that there is more than one choice.
The dialog field is defined as "Refresh fields on keyword change," "Refresh choices on document refresh" and "Display entry Help button." So far we are very standard drop-down list, right?
I have another field on the form that is hidden (the user cannot interact with it). I want to compute some value to be placed into this hidden field when the keyword in the field changes. The trick is that the computed text in the hidden field is going to show or hide an action button also on this form.
In other words, I want an event to occur when the user changes a dialog list, which I can capture and then process something without the user interacting with the screen in any other way.
I know about an onExit event, but this assumes that the user has moved out of the field, which is not the case. I know about an onEntry event, but the user has not made a change yet. I know that I could process the document (and fields it contains) when the user clicks the Action button -- but the button is hidden until the user has made their choice.
How do I do it?
The "Refresh fields on keyword change" option does trigger immediately when the field value changes, not waiting for you to exit the field -- provided the field keywords are of the "Enter choices" or "Use formula" type. The hide formula for your action button should recalculate immediately when the keyword field changes. Action hide formulas calculate after all the fields, so the newest value of your computed field should be used. I tested it myself with a simple form; here it is:
Field: AKeyword Datatype: Keywords Field Type: Editable Keyword User Interface: Standard Allow Values Not In List: No Allowable Keywords: A B C Field: Acomp Datatype: Text Field Type: Computed Formula: @If(AKeyword = "B"; "1"; "0"); Action: peekaboo! Formula: @Prompt ([Ok]; ""; "Peekaboo!"); Hide formula: AComp != "1"
If you need this functionality with a field that is not an "Enter choices" or "Use formula" keyword field, while there is no event that you can program to trigger as soon as the field changes.
However, you can use a NotesTimer object to check periodically -- say, once every second -- whether the field value has changed; if it has, you refresh the form. Add code to the form Postopen and Postmodechange events to notice when someone has started to edit the form; read the current field value using NotesUIDocument.Fieldgettext and store that in a global, then start the timer. In the NotesTimer event handler, use Fieldgettext again and compare with the stored value. If it's changed, refresh the form.
Warning: Refreshing the form can potentially take more than a second, especially if the form contains some @DB functions. You should disable the timer while doing the refresh, because if another timer event happens while you're processing the previous event, the Notes client will crash.