OrgReady

Salesforce Skills & Readiness

Learning progress is unavailable. Reading and direct practice remain available; completion controls are disabled.

← Back to Salesforce Development

Lesson 3 of 6 · 5–10 minutes including the walkthrough and reflection

Trigger Context & Trigger Design

The trigger event determines which data is available and where a change belongs. Choosing the wrong context can lead to unnecessary writes or incorrect comparisons.

The concept

Before triggers can modify the incoming records before they are saved. After triggers are useful when working with saved record information or related records; their triggering records are read-only. Context availability varies by operation, so code must not assume every event supplies both old and new values.

Worked example

Illustrative routing:
before insert -> validate/normalize incoming values
before update -> compare incoming values with prior values
after update -> consider related-record work
Only run the branch appropriate to the event.

Consider a value that needs normalization before insert. A before-event transformation acts on the incoming value. Separately consider an update that changes nothing relevant: the design should explain why unrelated work need not repeat. Keep business decisions explicit and test each supported event.

Common mistake

Using a context variable without checking that it is available for the event, or writing back to the same records without explaining why.

Interview angle

Explain the event, available inputs and desired side effects before choosing a trigger structure. A handler name alone does not establish correctness.

Pause and apply

Draw a small event table for insert, update and delete using the official context documentation. For each event, identify which data your proposed rule needs. Explain which cases your implementation intentionally does not support. Keep the example generic rather than writing a solution for the later checkpoint.

Official references

Reviewed 2026-09-13. Examples are illustrative; no code is executed here.

Apply it in practice

Apex Trigger Context & DML Fundamentals

Marking a lesson as read records learning activity, not mastery. Practice evidence continues to come from the challenge system.