A trigger is a SQL procedure that performs an action when a transaction
(INSERT, UPDATE, DELETE) occurs. You can use triggers to perform validation
of input data, to automatically generate a value for a newly inserted
row, to read from other tables for cross-referencing purposes, or to support
alerts through e-mail messages.
A database refers to data organized and stored on a computer that can
be searched and retrieved by a computer program. Most industrial-strength
and many smaller database applications can be addressed using SQL (Structured
Query
Language).
A query is a SQL command that will extract information from the tables
of a database. Essentially, a query is a request for information from
your database.
A transaction is a group of SQL statements whose effects are logically
connected. Anything from simple queries to inserting, and deleting operations
can be considered a transaction, as well as more complex groups of several
statements which accomplish a specific task.
Add Transaction Fields
The Add Transaction Fieldstrigger
allows the adding of fields that do not appear in the form on page, but
are taken into account when inserting the new record into the table (as
they are present in the database).
It is a BEFORE trigger, and therefore it gets executed before the actual
Insert/Update/Custom Transaction, but after
the page has been submitted. This way, in order to compute the transaction
field's value, other fields from the form can be used. Also, this trigger
is executed after the validation has been performed, which guarantees
that only coherent and correct data is taken into account.
As an example on where it can be used, consider the insert page for
adding a new product into a database table. The table contains both price and price_with_taxes
columns, but only price is requested in the
form. To add the second price, you can use an Add
Transaction Fields trigger which will compute the second price
based on the value submitted with the form for the regular price.
To add an Add Transaction Fields trigger
to your page, follow the next steps:
Access the trigger from the Application
panel, Server Behaviors -> + -> MX Kollection
-> Forms -> Advanced -> Add Transaction Fields.
Complete the dialog box that pops-up, following the
instructions below for each of the two tabs:
· The
Basic tab
· The
Advanced tab
Click OK when done.
The Basic tab
In the first step of the dialog box you should select the fields to be
added, and specify their type and value:
To set the dialog box options, follow the next steps:
In the Columns area
specify the table columns you want to add to your HTML
form from the insert page. You can add columns using the Plus (+) button.
The Minus (-)
button is used to remove fields from the form.
Specify the required settings for each
added data-entry in the HTML form by selecting
a row (single click) in the Columns area
and entering the required information in the boxes below the grid. Read
along for instructions.
In the Type drop-down
menu select the data format accepted by your database table. All the options
that you have are listed here: Text, Numeric, Double, Date.
In the Value text box
specify the value for the selected table column. You can use the InterAKT
Dynamic Data (the lighting bolt icon) to build complex expressions.
The three buttons in the top right corner of the
interface offer you the next functionalities:
· Click OK when you are done configuring the trigger.
· Click Cancel to exit without applying the new settings.
· The Help button opens this help page.
These buttons are common to both tabs of the Add
Transaction Fieldstrigger.
Click on the Advanced
tab to continue with configuring the trigger.
The Advanced tab
This step of the configuration requires the user to set the trigger's
name and some transaction options:
To set the dialog box options, follow the next steps:
In the Trigger name
text box enter an identifier (a name) for the trigger. Be careful when
choosing it, because it has to be unique on each page since it is also
the function name. By default, MX Kollection 3
assigns unique names to each trigger, and this setting should not be changed,
unless you really know what you are doing.
In the Transactions
area, the transactions to which the trigger is registered are displayed.
You can add new transactions manually, by using the Plus
(+) button:
The Minus (-)
button is used to remove transactions from the grid (select the transaction
first, with a single click).
At least one transaction
must be in the area at all times.
Specify the required settings for each
transaction listed above by selecting a row (single click) in the Transactions area and entering the required information
in the boxes below the grid. Read along for instructions.
In the Priority text
box specify the trigger's priority to execute when working with the currently
selected transaction from the grid. The higher the value is, the later
it will be executed.
In the Type drop-down
menu you can read the trigger type.
The drop-down menu appears disabled because it is a read-only field. The
allowed trigger type in this situation is BEFORE, but all the possible
trigger types are: STARTER, BEFORE, AFTER, END, ERROR.
In the Condition text
box specify the condition that has to be fulfilled for the trigger to
be executed (the start condition). To create the condition in a visual
manner, click the Build condition button.
It will open the Condition Builder
dialog box.
After configuring the user interface, click OK to apply the trigger,
or Cancel to dismiss it without making any
changes to your page.