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 readingAuthor Archives → Kamal Thakur
Salesforce 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 readingAgentforce is not enough for Salesforce Developer
It’s June 2025, eight months since Agentforce became generally available. I’ve witnessed it tackling numerous Salesforce challenges effectively. But despite the rapid evolution of AI, I still notice developers and companies feeling cautious about fully embracing Agentforce. What’s holding developers back?
Could it be the mandatory enabling of Data Cloud? Salesforce clearly emphasizes how Data Cloud enhances AI results. However, if a developer or admin isn’t planning to fully leverage Data Cloud, they’re still required to enable it, even minimally in their Salesforce org just to get Agentforce running. Understandably, this might cause frustration. Although Salesforce clarifies that core Agentforce features work seamlessly with existing CRM data without a full Data Cloud setup, the technical necessity of enabling it, even minimally, might deter some users.
Continue reading