<NOT/> Negation in dynamic forms
Negation of a global expression is possible in a rule using the <NOT/> tag:
<NOT>
Expression 1
Expression 2
...
Expression n
</NOT>
<NOT/> can be implemented in the value determination area of the rule definition (or for the definition of a precondition) and is used to form an expression with the opposing logical value for the logical value of a logical expression, for example, if:
- the expression a is 'true', then the negation is 'false'
- the expression a is 'false', then the negation is 'true'
Negation of a logical expression can be specifically used in a rule to prevent executing the rule, depending on certain conditions (precondition is NOT fulfilled) or to force validation (validation is then executed as long as the condition is NOT met) (see Structure of a rule).
<NOT/> is especially ideal when an “undesired” property is to be checked in a form, such as EMPTY, for example. This property can be used to prevent saving of an empty input component in the form. The expression <PROPERTY source="st_text" name="EMPTY"/> is always TRUE for an empty input component. Validation is not executed in this case, and saving the empty input component is not prevented:
<ON_SAVE>
<WITH>
<PROPERTY source="st_text" name="EMPTY"/>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="st_text" name="VALID"/>
<MESSAGE lang="*" text="The editor must not be empty!"/>
<MESSAGE lang="DE" text="Der Editor darf nicht leer sein!"/>
</VALIDATION>
</DO>
</ON_SAVE>
However, if the condition within the value determination area is negated, the rule supplies the desired behavior. When attempting to save the form with the empty input component, an error message appears below the input component and saving is prevented:
<ON_SAVE>
<WITH>
<NOT>
<PROPERTY source="st_text" name="EMPTY"/>
</NOT>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="st_text" name="VALID"/>
<MESSAGE lang="*" text="The editor must not be empty!"/>
<MESSAGE lang="DE" text="Der Editor darf nicht leer sein!"/>
</VALIDATION>
</DO>
</ON_SAVE>