Formulas are expressions that, once evaluated, return a certain value.
When an attribute or variable value can be calculated from other attributes, variables, constants, methods, arithmetic operations, etc., it can be defined as a Formula. In addition, when this assignment is done associated with an attribute definition (that is, for the attribute, inside the Transaction Structure where it is specified), the attribute itself is known as a Global Formula.
There are two ways to define formulas:
- Global Formulas (Global definition, at the Knowledge Base level)
- Local / Inline Formulas (Local definition, within objects' code)
Formulas can be classified into three groups, depending on the type of calculation needed. This classification is valid either for global or local formulas.
All these kinds of formulas may have trigger conditions.
Note: When defining a formula, you don't need to indicate if it belongs to one classification or another. This is only an external classification.
The table that is navigated in order to evaluate the formula is known as its base table. Depending on the kind of formula, the evaluation will consider only one record (horizontal formula) or many (aggregate formula).
Defining formulas is even better than writing Procedure objects and invoking them.
When you define a formula, GeneXus has the knowledge of its definition and is able to generate optimized sentences by combining the formula query with the query in which the formula is present.
On the other hand, if you define a Procedure and invoke it, the Procedure code is not "visible" from the invoker, and GeneXus can't combine the knowledge and generate the most optimized code.
Changes in Formulas terminology