How should you manage the API version of Apex classes in Salesforce?
What is the best practice for managing the API version of Apex classes in Salesforce? When you have older Apex code written 12–18 months ago with API versions between 27.0 and 29.0, should you leave these versions as they are, or should you regularly update them to newer API versions?…
How to Fix ContentDocumentLink Duplicate Errors?
When uploading files using <lightning-file-upload> in an LWC, Salesforce automatically creates a ContentDocumentLink between the uploaded file and the record-id provided. In your case, you are also creating another ContentDocumentLink in Apex to the same contact. This creates a conflict and causes the error: So the main issue is that…
How Do I Bulkify Queries for Related Records in Apex?
How can I properly bulkify my Apex code when I need to query records that are directly or indirectly related to a collection of input records, such as Trigger.new or a list of SObjects? When I place queries inside loops, Salesforce throws SOQL limit errors. What are the best patterns…
Live Agent in Lightning Communities with Locker Service?
I have been trying to implement Salesforce Live Agent within a Lightning Community Component. Before enabling Lightning Locker Service, the implementation was working perfectly. I placed the hosted deployment.js file in the Header Markup of the Community Builder and created a simple Lightning Component to display online/offline Live Agent buttons….
Why is component.find().getElement() undefined in Aura Components?
When working with Aura components, developers often encounter situations where component.find().getElement() returns undefined or becomes inaccessible, especially after setting breakpoints or using debugger statements in the init event handler. This issue became more noticeable after the Winter ’17 release when Locker Service was fully enforced. The problem is tied to…
Can we use the event’s “path” attribute in Lightning Components?
When developing Aura or Lightning components in Salesforce, we often deal with events such as onfocus, onclick, or onchange. These events help us detect user actions and update component data accordingly. One common situation occurs when you have a repeating list of elements — for example, a list of input…
What is the best way to get the Record Type ID in Apex?
When developing in Salesforce, especially for managed packages or production-grade Force.com applications, one common question arises: What is the best approach to retrieve a Record Type ID in Apex? There are a few ways to get the Record Type ID of a specific record type, but choosing the right one…
How do I effectively test asynchronous Apex in Salesforce?
Testing asynchronous Apex in Salesforce requires a slightly different approach compared to testing synchronous code. Asynchronous Apex includes any process that runs outside the main transaction, such as @future methods, Batch Apex, Queueable Apex, and Scheduled Apex. Because these processes are executed asynchronously by the Salesforce system, there is no…
How do I call the Salesforce API from a Lightning Component?
When working with Lightning Components, you may run into scenarios where you need to make API calls to Salesforce itself, such as calling the Metadata API or querying org limits. A common issue developers face is that there is no direct way to acquire a valid API session ID from…
How to use Fieldsets with Lightning?
Fieldsets in Salesforce are powerful because they allow admins to decide which fields appear on a form without developers hardcoding them. When using Lightning Components (Aura), we can render dynamic fields based on a fieldset. The challenge is that Aura-enabled Apex methods cannot return a FieldSet directly. There are two…


