Using macros sc_begin_trans, sc_commit_trans and sc_rollback_trans with Alert Message

Using macros sc_begin_trans, sc_commit_trans and sc_rollback_trans with Alert Message

When we need to maintain a control or follow-up to a specific procedure at the time of entering, modify some procedure within the database within a form we have the macro sc_begin_trans.


The macro sc_begin_trans is responsible for carrying out a transaction control procedure within theScriptCase, but it can also be complemented with the sc_commit_trans and sc_rollback macros.


Now, the macro sc_commit_trans takes care that once the control process has been carried out, it can be by means of a condition, confirms the transaction, that is, if all the proposed conditions are fulfilled, confirms the transaction, it can be the to insert, modify or delete a record.


Otherwise the macro sc_rollback_transque is responsible for canceling the transactions given by the user, for example, when wanting to enter, modify or delete a record, this is responsible for canceling or omitting the procedure.

To show an alert message we will use a JavaScript function that is responsible for displaying the alert message.

Then, in the following example, it is responsible for making a control when registering:

1. Within the onAfterInsert event, it performs a control after entering by means of a condition:



2. The changes are saved, and when you save a record with the name Brazil, it does not allow you to store it.


    • Related Articles

    • Using the macros sc_begin_trans, sc_commit_trans and sc_rollback_trans

      When we need to maintain a control or follow-up to a specific procedure at the time of entering, modify some procedure within the database within a form we have the macro sc_begin_trans. The macro sc_begin_trans is responsible for carrying out a ...
    • Using the sc_confirm macro

      In this article, see a practical example of using the sc_confirm macro. This macro can only be used on PHP buttons created in the toolbar of form and control applications, with the aim of confirming the action's excursion. See how to create a PHP ...
    • Show Question Message with SweetAlert - sc_alert

      To use the new SweetAlert functionality and display a question message, the following parameters must be taken into accoun:   When executing it would look like this:
    • Using sc_ajax_refresh()

      -Create a grid -At the Ajax Event -New Ajax Event: -Select the Event onClick and the desired field, and create: -Add the following macro: sc_ajax_refresh (); -When clicking on the record in that field, the page would be reloading Corresponding ...
    • sc_alert - Show Error Message with SweetAlert (error)

      To use the new SweetAlert functionality and display an error message, the following parameters must be taken into account:   When executing it would look like this: