4D v16Triggers |
||
|
4D v16
Triggers
Triggers
In addition to the manipulations explained in the video, you should also note that: By calling an ENGINE event, there’s an important precision to note: triggers are executed on the triggers database engine:
Generally speaking, get used to creating project methods that take care of your processes, calculations, etc. and call these “generic” methods from specific methods such as triggers. We saw how to pass parameters, so make good use of it! It’s a lot easier to maintain and you save a considerable amount of time developing as well as bug fixing. Your code will be a lot more concise, reliable, and readable. You can execute cascading triggers. In this case, 4D has commands that allow finding out the trigger properties and its cascade level. A trigger can also serve to "accept" or "reject" any operation attempt on the record. This is a way to allow you to ensure the integrity of your database regardless of how information is processed:
Knowing that a trigger blocks the other processes during execution, the main rules to follow in a trigger are:
In this video, we're going to learn how to configure database events and how to take them into account in the programming.
In that sense, a trigger is a method like any other. It's simply the context in which it is executed that changes. Like form events, database events must be checked so that 4D gives control to the trigger to execute. We can enable any database event in the Table inspector. You’ll find the “Edit” button at the bottom right, which allows creating the method to execute when the checked events occur. The method is generally structured in the following manner: $evt:=Database event `What is the number of the event being executed by the database event? Unlike a form method that is only executed during a display (or print), a trigger is executed regardless of how you access records:
The trigger has the advantage of being a mandatory passage point.
[Interventions]Date_Last_Modified:=Current date Of course, this latest modification will also be valid when creating a record. Let's try it out by performing a modification:
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
Self-training ( 4D v16) |