Executive summary Salesforce asynchronous execution is not a single feature. It is a family of distinct runtime models with very different guarantees around transaction boundaries, ordering, retries, state transfer, user context, observability, and scale. The durable “server-side async” tools are Queueable Apex, Batch Apex, Scheduled Apex, Future methods, and event-driven subscribers such as platform event… Continue reading
Advanced Salesforce Integrations Guide
Executive Summary Salesforce integrations should be designed from the outside in: start with business timing, user experience, data ownership, failure tolerance, compliance constraints, and expected scale, then choose the narrowest technology that solves that exact problem. Salesforce’s own architecture guidance is explicit on several high-level principles: avoid unnecessary data replication when virtualization is sufficient, favor… Continue reading
Recursion in Apex: Avoiding Trigger Loops and Embracing Proper Use
Recursion in Apex has a bit of a reputation. Many Salesforce developers first hear the term when a trigger unexpectedly calls itself over and over, leading to the dreaded “Maximum trigger depth exceeded” error. It’s easy to assume recursion = bad, especially if you don’t come from a computer science background. In reality, recursion is a fundamental programming concept, a powerful tool when used intentionally, but a source of tricky bugs when it happens unintentionally. This post will simplify recursion in the context of Apex, exploring both the pitfalls of unintended recursive triggers and the value of deliberate recursion for solving certain problems. We’ll look at code examples of each, discuss how recursion interacts with Salesforce governor limits and performance, and cover best practices (like static flags and trigger patterns) to prevent unwanted loops. By the end, you’ll know when to fear recursion, when to embrace it, and how to keep your triggers from going rogue.
Continue readingSalesforce Record Locking and Concurrency – Salesforce Things You should Know
If you build on Salesforce long enough, you will hit a lock. This post explains how Salesforce Record Locking and Concurrency work, why you see UNABLE_TO_LOCK_ROW, and how to write code that behaves correctly under load.
Salesforce Query Plan – Salesforce things you should know
This is Part 2 of Salesforce things you should know. In Part 1 we covered Selective Queries and Indexes. Now let’s turn that theory into practice with the Query Plan. If you want predictable SOQL performance, this is the tool you open before you deploy your code.
Continue reading