Every Salesforce engagement eventually faces the same question: should we build this with configuration, or do we need to drop into Apex? Get the answer wrong and you will pay for it in technical debt for years.
The decision framework
- Step 1: Can Flow or declarative tools do this? If yes, use them.
- Step 2: Will declarative work but only just barely? Build it declaratively anyway and document the boundary.
- Step 3: Is this a one-off business process or a reusable pattern?
- Step 4: How often will this change? Custom code is harder to change than configuration.
- Step 5: Who will maintain this in three years? Will that person know Apex?
When to use Apex and LWC
You are building a reusable component used in many places. The logic is genuinely complex (multi-object, multi-step, with branching that does not fit Flow). You need performance that declarative cannot deliver. You need integrations that require explicit error handling.
When to stay declarative
Single-object automation. Simple field updates. Approvals. Most validation rules. Workflows your admins will edit regularly. Anything where "who will own this in two years" is an admin, not a developer.