Official Content

In addition to all the automatic controls included by GeneXus in the applications it generates, sometimes users request some specific controls. In Transactions, the rules that must be complied with, or the controls that you are asked to validate, are defined in the #Rules section.

If, for example, a requirement is not to allow storing of products without a name, GeneXus offers a rule called Error that will enable you to avoid that:

TrnProductRule_Gen_Web

Press F5 and GeneXus will save and evaluate the new definitions included the Knowledge Base. In this case it will infer that it is not necessary to modify the database, so it will not show an Impact Analysis Report. GeneXus will generate the necessary code and after that, it will execute the application updated with the new definitions.

Run the Product Transaction. Note that if the product name is left blank, the rule you have defined is executed: 

DeveloperMenu_errormsg_Gen_Web

There is another rule whose syntax is very similar to the Error rule. It is called Msg and the only difference between them is that if the condition is met, in this case the message is displayed as a notice or warning, and the user can continue working. 

If, for example, you want to inform that the product's price has been left blank without forcing the user to enter it, you can add the following rule in the Product Transaction:

TrnProduct_msg_Gen_Web

This set of rules could be written in any other order and the result at runtime would be exactly the same, because GeneXus decides when each one of the defined rules should be triggered (when the user leaves each involved field, etc.). 

Of course, GeneXus offers more available rules to define different kind of validations and actions. 

Each Transaction may need to have its own behavior rules defined. 

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant