Salesforce

Trigger Events (Magic xpi 4.13)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

Trigger Events (Magic xpi 4.13)

Once the DB Trigger Service is configured and validated successfully, the user can configure the events to be captured by clicking the Events button. It will open the Trigger Events dialog. Here, the user can define multiple events, add tables to them, configure the create, update and delete events which need to be captured for those respective tables.

The Trigger Events dialog box consists of two panes. The left pane displays the list of events added. The event name will itself be the name of the trigger. The user can create new or delete existing event(s) by clicking the Add or Delete buttons.

On the right pane, the user can associate table(s) to the selected event. The grid where the tables can be added contains the following fields:

Parameter

Description

Table Name

Name of the table for which the CRUD events have to be captured. To add a new entry to the list of Table Name, click the Add button. Click (ellipsis button) to open the Table List and select a table. Table List will show all the tables from the selected database.

  • If a table is added to one event, then it cannot be added to another event for the same action(s).

  • The table should not be used more than once across multiple projects.

Create

Select this check-box to capture the create event on this table. If any row is added to the table, a row will be added to the TriggerAction table.

Update

Select this check-box to capture the update event on this table. If any row is updated in the table, a row will be added to the TriggerAction table.

Delete

Select this check-box to capture the delete event on this table. If any row is deleted from the table, a row will be added to the TriggerAction table.

Copy to Clipboard

Click (ellipsis button) given at the end of each entry, to open the DBTriggers Scripts dialog box for the selected table entry. The dialog box will contain the trigger creation script. This is the template script. The user needs to edit the payload structure before executing the script in the database. To copy the script to clipboard, click the Copy to Clipboard button.

Once the events are added, click OK button to save the events. After the events are saved, the Studio will generate a template SQL script at location: DBTrigger\<DB Trigger Service Name>\EventActionScripts.

This script will have triggers' definitions generated for the tables selected in the event. The script will have the default payload structure. The user will have to edit it and change the payload structure, before execution. The maximum payload size should not exceed 1000 characters otherwise the insert operation in the TriggerAction table will fail.

  • It is user's responsibility to run this SQL script in the database before starting the project. For more information, refer the Running the DB Trigger Scripts Manually section given below on this page.

  • For PostgreSQL type of database, if the table is selected from database schema other than public schema, then the user has to add the schema name before the table name in the generated script. This change needs to be done in the CREATE TRIGGER statement for the selected table(s).

Running the DB Trigger Scripts Manually

The Copy to Clipboard operation will generate a template for the DB Trigger script(s). The template just provides the user with a quick start and should not be run as-is. The user has to do some adjustments before running the script(s).

The Copy to Clipboard operation generates a combined script for all the events. If the script has more than one event (Create, Update, and Delete), the script for each event should be run separately. Before running the scripts, the user will have to adjust the payload values.

Reference
Attachment 
Attachment