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 readingSelective Queries and Indexes – Salesforce things you should know
I am starting a new series on Salesforce things you should know. Not sure how long I can do this but surely try to keep up. To start with lets jump into one of the salesforce’s most overlooked topics when it comes to Queries – Salesforce Selective Queries and Indexes.
Continue reading