Every now and then you run across something in Notes that you had somehow missed. Today, I found one of those nuggets. We all know that Notes 6 introduced a number of JavaScript events for fields. Events like onFocus, onBlur, and onChange were added to make it easier for Notes developers to add JavaScript to web applications. While a large portion of the new events are JavaScript only, the 3 mentioned can also have LotusScript code run in the Notes Client. Until today, that option had totally missed my radar screen.
We all have had requests to have Notes do something when the values in a field changed. The way I used it was to create a global boolean variable on the form, set that value to true using the onChange event, and then doing something in the QuerySave if the variable is true. That is so much better than trying to use the Entering and Exiting subs to track field changes by comparing the start and end values.
Of course, it would be totally rad if these 3 field events were Read/Write instead of Read-Only. That would really allow a robust framework to be written for the Notes Client, MVC style.
Created 1/31/2008 10:03:19 PM email | website
This is so simple and easy... everyone should know this...
<must go try this out tomorrow!>
:-)
Created 2/1/2008 7:06:46 AM email |
At least onBlur works in R5 as well. I am still stuck on that version, and I use it to validate phone number, for example. That works both in the Notes client and on the web.
onChange I am having some problems with in the client, though, at least for certain field types.
I am actually working on a form validation class/script library, and it will also contain a method that return a list of changed fields, as well as their values. Will post it on OpenNTF.org when I have it done.
Created 2/2/2008 7:29:25 AM email | website
I've been using it too. There is also a easy way to make JavaScript run functions/commands, just create a hidden button with the function an have the JavaScript 'click it'