thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Business Platforms & EA · Foundational

Apex Trigger

Apex code that executes before or after insert, update, delete, merge, upsert or undelete events on a record.

Definition

Before triggers are used to validate or update the same records without DML; after triggers access system-set fields like Id and change related records. Best practice is one trigger per object delegating to handler classes.

Example

trigger AccountTrigger on Account (before insert, after update) { AccountHandler.run(); }

Exam tip

Use before triggers for same-record field updates; after triggers when you need the record Id.

Related terms