I’m trying to construct a form in order to implement the following functionality:
When the value in one field (Field1) is changed, the value in another field (Field2) must also be changed before the form can be saved. If the user changes Field1, they must also change Field2 or else they can’t save their changes.
I have the following fields:
Field1 (Checkbox - Editable, Default value = “”, Enter choices one per line = Yes)
Field1OnOpen (Text - Computed for Display, value = Field1)
Field2 (Text - Editable, Default value = “”)
Field2OnOpen (Text - Computed for Display, value = Field2)
The Input Validation formula for Field2 is as follows:
The Field1OnOpen and Field2OnOpen values seem to be calculating correctly, however no error (failure) is received when the form is saved and closed, despite the fact that I change the value in Field1 but leave Field2 as is.
Subject: What’s wrong with this Input Validation code/logic?
Everytime you change the value of field1 and field2 it’s always equal because you have set it as computed for display. In your validation formula you can never reach the condition Field1 != Field1OnOpen its always equal.
Tre changing the field1OnOpen to computed when compose then you will see what I mean.
Subject: RE: What’s wrong with this Input Validation code/logic?
Or better yet, leave Field1OnOpen as Computed for Display, but change its formula to:
@If(@IsDocBeingLoaded; Field1; Field1OnOpen)
Or, make the fields non-editable and use a dialogbox to prompt the user for two new field values; then you can compare what they enter with the current values and decide whether they did OK.
Subject: RE: What’s wrong with this Input Validation code/logic?
Thanks for the replies.
The problem was caused by the Computed For Display fields / formulas, which were recalculating to the modified Field1 / Field2 values, so Field1OnOpen could never != Field1 despite what was visible on the screen prior to pressing F9 (of course!).
I’ve changed the CFD formulas to @If(@IsDocBeingLoaded;Field1;Field1OnOpen) as Andre suggested and now it works (as the Field1OnOpen and Field2OnOpen values are effectively only calculated when the form is loaded).
Subject: What’s wrong with this Input Validation code/logic?
Paul,The way you are comparing itself is not OK. When ever Input validation event runs it computes the values. You are storing the values in computer for display fields to compare with change in the editable field. This can be achieved simply by using Lotus script. declare global variables in (Globals)-(Declarations) for both tmp1 and temp2 and assign the field values of filed1 and field2 on open event. and when you edit compare the field1=tmp1 and field2=tmp2…and get the thing. This is a better way to do get the task done without any problems.