Most real plugin work is a variation on a small number of patterns. This chapter is a reference: real scenarios developers build plugins for, grouped by category, with the message and stage each typically uses.
Data integrity
| Scenario | Typical message / stage |
|---|---|
| Prevent deletion under a condition (e.g. a Won Opportunity) | Pre-validation, Delete |
| Real-time field validation too complex for a Business Rule | Pre-validation, Create/Update |
| Custom duplicate detection beyond the built-in rules | Pre-validation, Create |
| Dependency checking before allowing a delete | Pre-validation, Delete |
Example
A plugin blocks deleting an Account if it still has open Opportunities: pre-validation on Delete, query for related open records, throw
InvalidPluginExecutionException if any are found — nothing is removed before the check runs.
Automation & notifications
| Scenario | Typical message / stage |
|---|---|
| Cascade updates to related records (e.g. an address change flowing to Contacts) | Post-operation, Update |
| Automatic record assignment by territory or workload | Post-operation, Create |
| Status-change notification when a record crosses a threshold | Post-operation (async), Update |
| Calculated fields derived from other fields | Pre-operation, Create/Update |
| Auto task creation after an event (e.g. a new Case) | Post-operation, Create |
Example
A high-value Opportunity moving to "Negotiation" triggers an async post-operation plugin that emails the sales manager — not time-critical, so it runs after the rep's save has already completed.
Auditing & escalation
| Scenario | Typical message / stage |
|---|---|
| Custom audit/history logging on specific field changes | Post-operation, Update |
| SLA-style escalation when a time-based threshold is at risk | Often paired with a scheduled/async job |
Integration
| Scenario | Typical message / stage |
|---|---|
| Calling an external system when a record changes (e.g. posting an order) | Async post-operation, Create/Update |
Example
When an Order is confirmed, an async plugin posts the order details to an external fulfillment API. Running async means a slow or briefly unavailable external system doesn't hold up the user's save.
Key takeaway: Almost every plugin you'll build fits one of these patterns — blocking or validating something (pre-validation), reacting after a save (post-operation), or handing off to something slower (async). Recognizing the pattern usually tells you the stage and mode before you write a line of code.