Table- and entity-level scripts

Table- and entity-level scripts are an alternative method of creating SQL triggers that can be performed in the Sage CRM system. The Extensibility Module is required to create and customize table- and entity-level scripts.

Table-level scripts are executed when a record is inserted, updated, or deleted on a specified Sage CRM table. Entity-level scripts are executed when a Sage CRM entity is inserted, updated, or deleted.

Both table- and entity-level scripts can be executed on system tables or any tables that are connected to the system. Each script must have the following four functions defined: InsertRecord(), PostInsertRecord(), UpdateRecord(), and DeleteRecord(). These functions are automatically included in a template when you create a new script.

Compared to SQL triggers, table- and entity-level scripts provide the following benefits:

  • Improved database concurrency. The scripts are decoupled from the tables on which they are acting.
  • Easier debugging. The ErrorStr statement can be included to display diagnostic and handle error messages. If an unhandled script error occurs, the system displays the script name, line number, and the error message.
  • Smoother upgrade process. Before performing an upgrade, you have to disable all SQL triggers and then re-enable them afterwards. This is not the case with table- and entity-level scripts.

In this section: