Use transaction fields

Custom trigger code can access the columns of the transaction to which it is registered through the following methods of the tNG class:

You can use these methods to retrieve column value and use them for any processing - either before or after the transaction. Note that the primary key value can only be used in an after trigger, as it gets initialized only after the transaction has completed.

Example: the following example uses the Discussion Board tutorial database structure, and the post message page. When posting a new message, aside the regular information you have to enter in the form fields, an additional field has to be set after the insert operation: the id_init_msg field must be set to the same value as the new message ID. The custom trigger that is executed after the insert transaction performs an update on the last record and sets the correct values through an update transaction.

 

In the next section you will learn how to modify the value of fields involved in a transaction.