Skip to content
Groovy 25 – Trigger Performance and Avoiding Threshold Errors

Best performance when using scripting is obtained with the usage of "Before" triggers, such as:

  • Before Update in Database
  • Before Insert In Database

The reason is that when using "After" triggers (e.g., After update in database, After Insert in Database, After Changed Posted to Database, After Commit), the data was already sent to the database. With these triggers, you are doing new modifications to the record, requiring a second DML operation per modified row to send the modified data to the database for permanent storage. This multiplies the number of transactions between the Application and Database, slowing down performance.

Whenever possible, use Before triggers.

Another common issue with scripting is the error Post threshold limit reached. Some entities yet to be posted. This occurs when you use the After method setAttribute(). The value is set on a field and sent to the database, but before being inserted, it is subjected to internal ADF validations to ensure data integrity. Once the values pass validation, they are re-posted to the database. When that happens, the trigger may fire again, creating a cycle.

The easiest way to avoid this error is to use this technique:

        if (API_FIELD != Value) {
            setAttribute('API_FIELD', Value)
        }