In addition to all the automatic controls included by GeneXus in the applications it generates, sometimes users request some specific controls. In Transaction objects, the rules that must be complied with, or the controls that you are asked to validate, are defined inside the Source selector in the #Rules section.
If, for example, a requirement is not to allow storing products without a name, there is a rule called Error that will enable you to avoid that.
While you can define the rule yourself, you can also use a GeneXus Next assistant to facilitate this task. In addition to the general "AI Assistant" available in the window on the right, GeneXus Next also offers an assistant integrated into each object to ask directly in those objects what you need to solve. To do so, inside the Source selector (in the #Rules section or everywhere), type three slashes (///) to start the communication with the assistant and enter the following, for example:
///Check that no products are entered without a name

When you press Enter, the assistant suggests adding the following Error rule:
Error("Product Name cannot be empty") if ProductName.IsEmpty();
As the proposal is correct, type the Tab key to confirm.
Press F5 and GeneXus will save and evaluate the new definitions included in 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 code required to obtain the application updated with the new definitions.
Run the Product Transaction. Note that if the product name is left empty, the rule you have defined is executed:

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 need to inform that the product price has been left blank without forcing the user to enter it, you can write the following rule in the Product Transaction:
Msg("You have not entered the price") if ProductSalePrice.IsEmpty();
Alternatively, you can ask the assistant to warn users if they leave the price empty. To do so, you can type the following, for example:
///Show the message “You have not entered the Price” if the price is left empty

In one way or another, you define the same rule.
The set of rules could be defined in any other order and the result at runtime would be exactly the same because GeneXus Next decides when each defined rule should be triggered (when the user leaves each field involved, etc.).
Press F5 and run the Product Transaction. Note that if the product price is left empty, the Msg rule is executed:

Of course, there are more available rules to define different kinds of validations in Transactions.
Each Transaction may need to have its own behavior rules defined.
Defining business rules in the application