AfterValidate Triggering event

Official Content
This documentation is valid for:

If you add an AfterValidate triggering event to a transaction rule, you will be specifying that you want to execute that rule, for each instance of the level associated to the rule, immediately before the instance is physically saved (inserted, updated or deleted) in the physical table associated to the level. This triggering event hasn't got implicitly a certain operation (insertion, update, deletion) in the database. The execution is when the user has already confirmed and immediately before writing the involved table.           

Syntax

Any valid Transaction rule [ IF condition ][ ON AfterValidate] ;

Where:

condition
         Is any valid logic condition

Example

Let's suppose the Autonumber property isn't an option to number automatically a primary key attribute because the user asks for a particular numeration with a certain criterion (with alphanumeric characters). So, we must solve it by programming a procedure object. 

To call the numbering procedure, we must define a rule like the following, in the transaction that requires the particular numeration for its primary key (let's suppose the Flight transaction):

FlightId = NextFlightNumber() if Insert on AfterValidate;

It is not important for us in this moment to know the NextFlightNumber procedure code. If we read this rule defined in the Flight transaction, we know:

  1. The procedure is returning a value for the primary key
  2. The rule is executed if the user is inserting a flight (because of the if insert condition explicitly added to the rule)
  3. Immediately before the first level data is inserted as a record in the FLIGHT physical table, the rule is executed  (because of the triggering event: on AfterValidate and the fact that the only referenced attribute in the rule belongs to the first level transaction).

Notes

  • This rule definition is appropriate because the procedure call is executed before inserting the record in the table. In other words, the insertion has been confirmed by the user, but it has not yet occurred. So the value returned by the procedure is assigned to the FlightId attribute, at the time of writing the Flight record.
  • If no attribute were specified in the rule, the first level is assumed to trigger the rule. 

Scope

Objects   Transaction object

Compatibility

The After(Confirm) triggering event is maintained for backward compatibility reasons. We highly recommend using the AfterValidate event instead. For further information see Triggering Events.

See also

Transaction rules
Rule Triggering Events

 




Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.