<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:
<RULE>
<WITH>
<PROPERTY source="st_text" name="EMPTY"/>
</WITH>
<DO>
<VALIDATION scope="SAVE">
<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>
</RULE>
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:
<RULE>
<WITH>
<NOT>
<PROPERTY source="st_text" name="EMPTY"/>
</NOT>
</WITH>
<DO>
<VALIDATION scope="SAVE">
<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>
</RULE>
As an alternative, the negation can be carried out within a <DO/> tag if the result of the value determination is a Boolean value.
Example:
<RULE>
<WITH>
<PROPERTY name="EMPTY" source="st_text"/>
</WITH>
<DO>
<NOT>
<VALIDATION scope="SAVE">
<PROPERTY name="VALID" source="st_text"/>
<MESSAGE lang="*" text="The editor must not be empty!"/>
<MESSAGE lang="DE" text="Der Editor darf nicht leer sein!"/>
</VALIDATION>
</NOT>
</DO>
</RULE>