First off, if the values are text, then this isn’t very good validation. “759025766543” is greater than “751” and less than “769” when compared as text.
Validation really should be done in the QuerySave if there is not a business need to have it in the field. This (1) keeps the code in one place and makes it easier to manage; and (2) reduces the number of refreshes a user has to deal with as each field gets validated.
I’m afraid I have to strongly disagree – I would prefer that all validation be done in the provided validation events because it’s obvious (indicated by the little icon in the object browser), navigation to the affected field is immediate and automatic and it can optionally be made to fire in-process rather than waiting for a save. Each to his own, but since field validation and nav-back is unique per field, having all the code in one place is no particular advantage.
From a code maintainability purpose, I would argue it is better. When you have to make a change to an application, what is easier, slogging through each field or going to a common code base to make sure chnages do not impact existing validation.
Also, this allows you to move the definition of validation rules out of the code and into the hands of the business process owner.
Ain’t nuttin’ you can do in the QuerySave you can’t do in a Validation event (including getting profiled rules), and I still argue that it’s easier to “find” the validation code for a particular field when it is AT the field rather than on line 7223 of a library used in a library used in an event. I’ve never understood the centrality argument for object-specific code – the proper place for object-specific code is in the class/object.
I don’t want this to degrade to a religious war or anything – I can’t see any better, more logical, or more discoverable place for field validation than at the field itself. You have another opinion (that’s wrong ;o) ), and our poor victim has a choice.
If I may add my 2 cents here, i’d add a few comments.
If you put code in the query save event, you can argue that there might be SEVERAL query save events… for the main form, but for the subforms also if any… unfortunately for teh headache of the poor LN developer!
On the other hand, sometimes, you need to trigger a refresh: from a dialog box choice, from a button, from an event, etc. At this point all the validation formulas are triggered, which can be erally annoying since the user didn’t try to save or to check his values, and we only wanted that one specific value to be refreshed. In this situation, I prefer adding my validation formulas in the querysave - or in the workflow action, if it applyes to this form.
Okay, now – taking the middle road is wronger than being firmly in one camp or the other. File and I can only be wrong half of the time at most; you’ve allowed the possibility to be wrong all of the time, and when the religious war really starts, both sides will call you a heretic
I address this issue in “Better Compliance through Lotus Notes/Domino Coding” published in the Jan 2005 issue of “Lotus Advisor” ( http://lotus.advisor.com/doc/14900 ).
Your code will work for sure, but still need to get the ‘|’ symbol to work. I set a simple test and can not get the ‘|’ not matter how I rewrite the code.
Are you able to use the ‘|’ in a simplet test? If so, can you explain what I’m missing.
Stan’s question can be rephrased as “Do you know boolean operator precedence (or at least how Notes implements it, which isn’t quite correct), and therefore does your code do what you think it does?”