Skip to main content

Salesforce Developer

Explore practical guides and implementation patterns for this topic.

Posts

The Observer

Who Is The Observer?

⚡ 1-Minute Summary: " The Observer " is your built-in ability to watch your own thoughts, stress, and knee-jerk reactions without getting swept away by them. Real self-enquiry starts the exact moment you step back from the mental noise and simply watch what is happening inside your head. 💬 In plain words: The Observer is the quiet part of you that notices what your brain is doing. When you feel a sudden wave of anger, imposter syndrome, or excitement during a sprint, the Observer is the calm awareness in the background asking: "Who is noticing this feeling right now?" 📌 Example: Five minutes before a major production deployment in DevOps Center , a critical Apex test class fails with a MIXED_DML_OPERATION error. Normally, your brain screams, "I am completely stressed out and everything is ruined!" Stepping into the Observer shifts that inner experience to: "I notice that my heart is racing and panic thoughts a...
Read article
Lightning Web Components

Mastering LWC Data: @wire vs Imperative Apex & refreshApex

💬 In plain words: The @wire decorator is an automatic data subscription: it caches data, reacts to changes automatically, and serves as your default for reading information. Imperative Apex is a manual phone call: you decide exactly when to make it (like clicking a button or validating a step). Use refreshApex to update your wired data after an imperative action changes the underlying records.
Read article
Agentforce

Agentforce Instructions: Understanding Logic Lines vs. Prompt Lines

💬 In plain words: When building instructions for an AI Agent in Salesforce, you are actually writing two completely different types of code in the same list. Logic lines act like traditional code (fetching data, evaluating true/false). Prompt lines act like natural human English that the LLM will read. You use conditions to decide which prompt lines actually get sent to the model. 📌 Example: Imagine an agent checking a system outage. You use three logic lines to fetch and store the outage status. Then, you write two conditional prompt lines . One says, "Give the confirmed estimate," and the other says, "Say no estimate is available." Based on the logic lines, only one of those prompt lines will ever reach the model to guide its response.
Read article
Apex Development

Mastering Salesforce Design Patterns: Gang of Four (GoF) in Apex

💬 In plain words: Classic software design patterns translate beautifully to Salesforce Apex, but they look a bit different. The Singleton pattern ensures one shared instance per transaction (great for caching). The Strategy pattern lets you swap out business rules cleanly. The Factory pattern creates the right class dynamically based on configuration. Mastering these patterns—and knowing which ones the Salesforce platform handles natively—is the key to writing scalable, enterprise-grade code. 📌 Example: Config-Driven Validation Imagine your company handles global orders: US orders require a Tax ID, while EU orders require a VAT check. Instead of a massive if/else chain, use the Strategy pattern . Create one IOrderValidator interface and separate classes for each country. Then, use a Factory to read a Custom Metadata Type and load the correct class dynamically. When you expand to a new country, you just write a new class and add one config ro...
Read article
Apex Development

Dependency Injection in Salesforce Apex: Testability & Trade-offs

💬 In plain words: Dependency Injection (DI) simply means a class receives its tools from the outside instead of building them internally. By passing dependencies (like database selectors or API callout classes) into a class, you can easily substitute them with FAKE tools (mocks) during unit tests. This lets you test your core business logic instantly without making real database queries or external network callouts.
Read article
Topic LWC
Lightning Web Components

Best Trailhead Modules and Superbadges to Master Lightning Web Components (LWC)

In plain words: Trailhead is Salesforce's free, interactive learning platform that offers structured learning tracks (called Trails, Projects, and Superbadges) to help developers learn, practice, and validate their skills in building modern Lightning Web Components (LWC). Lightning Web Components (LWC) is the foundational UI framework for modern Salesforce development, built directly on standard Web Components, Shadow DOM, and modern JavaScript (ES6+). Whether you are transitioning from Aura or starting your Salesforce engineering journey from scratch, Trailhead offers self-paced, hands-on modules to help you master LWC architecture. Here are the top learning paths, reference resources, and credential tracks to fast-track your expertise.
Read article
Topic Apex
Apex Development

How to Serialize SOQL Query Results to JSON in Salesforce Apex

In plain words: To convert Salesforce Object Query Language (SOQL) results into a JSON text string in Apex, pass your queried SObject or List<SObject> directly into System.JSON.serialize(objectToSerialize) . If you need to strip out null properties, pass true as the second argument ( JSON.serialize(records, true) ), and if an external API rejects Salesforce’s automatic attributes metadata node, map your records into an Apex Wrapper Class first. Whenever your Salesforce org needs to send database records to an external Enterprise Resource Planning (ERP) system, a middleware layer like MuleSoft, or a custom front-end component, those records must be translated from in-memory Apex SObject instances into a universal text format. In modern web APIs, that standard format is JavaScript Object Notation (JSON). While turning a SOQL query into a JSON string takes only a single line of Apex code, the default output often surprises developers the first time an exte...
Read article
Topic LWC
Lightning Web Components

Top Essential Salesforce Developer Resources: LWC, SLDS, Tools & Documentation Guide

💬 In plain words: Instead of relying on general search engines that often surface outdated Aura or Classic forum answers, Salesforce developers can save time and avoid deprecated patterns by matching each task to its dedicated official portal—using the Component Library for base UI elements, SLDS for CSS styling, the Developer Documentation Index for Apex and API limits, and the sf CLI with Code Analyzer for local development. Navigating the Salesforce developer ecosystem can feel overwhelming when you are trying to build or debug a feature under a deadline. Because official references for user interface design, frontend components, backend Apex rules, sample repositories, and architectural patterns live across several subdomains, relying on a broad web search often leads you to ten-year-old Visualforce posts or retired command-line syntax. Knowing exactly which official portal answers which technical question keeps you aligned with current platform standards. B...
Read article
Lightning Web Components

How to Track IP Geolocation in Salesforce using LWC and Apex Callouts

Tracking user locations based on IP addresses is a frequent requirement for security auditing, fraud detection, and creating localized customer experiences inside Salesforce. While legacy systems relied heavily on Visualforce, modern Salesforce architecture dictates using Lightning Web Components (LWC) backed by an Apex REST callout to fetch and display this geographic data securely. In plain words: An LWC captures the IP address input by the user and passes it to an Apex class. The Apex class sends an HTTP request to an external geolocation API, receives a JSON package containing location details (like city, country, and time zone), parses it, and sends it back to the LWC to be displayed on the screen.
Read article
Apex Development

How to Get the Current User Profile Photo in Salesforce Visualforce

When building custom header bars, user profile cards, or personalized dashboards in Salesforce, displaying the logged-in user's profile picture adds a polished, personal touch. Accessing this photo in Visualforce requires querying the User object in Apex and binding the resulting image URL to your markup. In plain words: You can fetch the active user's avatar image by querying the FullPhotoUrl or SmallPhotoUrl field on the User object using UserInfo.getUserId() . Once retrieved, bind the URL to an <apex:image> tag to display the photo directly on your Visualforce page.
Read article
Apex Development

How to Add and Remove Multiple Parent and Child Records Dynamically in Salesforce

Although Lightning Web Components (LWC) are the standard choice for greenfield Salesforce interfaces, many organizations still maintain and extend Visualforce pages for internal onboarding wizards, bulk intake forms, and back-office data-entry screens. One of the trickiest UI patterns to build in Visualforce is a single screen where users can dynamically add or remove multiple parent records (such as Accounts) alongside multiple child records (such as Contacts) before committing everything to the database. In plain words: To let users click an "Add" or "Remove" button for both parent and child rows on one Visualforce page, you must group the records inside nested Apex wrapper classes . The outer wrapper holds one parent record and a List of inner child wrappers, while Visualforce loop counters pass the exact row indexes back to Apex so server actions update the right row without wiping out user input.
Read article
Topic LWC
Lightning Web Components

Migrate Visualforce Pagination to LWC: A Modern Server-Side Approach

In plain words: Server-side pagination in Salesforce Lightning Web Components (LWC) fetches one page of records at a time from Apex using SOQL LIMIT and OFFSET , while JavaScript tracks which rows a user checks across multiple pages. Instead of building stateful Apex wrapper classes just to hold a checkbox boolean—as was common in legacy Visualforce—you bind a lightning-datatable to a reactive selected-rows array and reconcile additions and removals per page in the browser. In classic Visualforce development, building a paginated table with checkboxes usually meant pairing a stateful ApexPages.StandardSetController with a custom Apex wrapper class (such as AccountWrapper containing an Account record and a Boolean isSelected flag). Because Lightning Web Components use stateless @AuraEnabled Apex methods, application state moves from the server view state to your client-side JavaScript controller. However, simply swapping Visualforce for LWC introduces two traps...
Read article
Salesforce Basics

Salesforce Async Apex Explained: The "Who Can Call Whom" Matrix

💬 In plain words: Navigating asynchronous Apex is all about knowing who is allowed to call whom. A Queueable can chain itself, and a Batch can start a Queueable . However, a @future method is a dead end—it cannot call another @future , and a Batch cannot call a @future . Memorizing this simple matrix eliminates an entire category of runtime crashes.
Read article
Agentforce

Salesforce Agentforce Best Practices: Return Decisions, Not Raw Data to LLMs

💬 In plain words: When building custom Apex actions for AI (like Agentforce or Einstein Copilot), never just hand the raw record to the Large Language Model (LLM) and ask it to figure out the answer. While the model will usually get it right, its occasional silent failures are impossible to catch. Instead, do the heavy lifting in your Apex code and return a clear, final decision (a verdict) alongside a plain-language explanation to the model. 📌 Example: Instead of passing a raw Service Contract and Case record to the AI to determine a refund, your Apex should process the logic and return specific outputs like: isEligible = true refundAmount = 1240 reason = "Supply was interrupted for 14 hours, which exceeds the 12-hour guarantee." Now, there is absolutely nothing left for the LLM to guess or infer.
Read article
Data 360

Salesforce Zero-Copy Federation Explained: When to Federate vs. Ingest Data

💬 In plain words: Zero-Copy means you do NOT move the data. Your rows stay exactly where they are—in Snowflake, Databricks, Amazon Redshift, or Google BigQuery. Salesforce Data Cloud reads them in place. That means no data pipeline to build, no expensive second copy to store, and no synchronization jobs breaking at 3:00 AM. 🎬 Real-Life Example: 500 Million Rows, Copied Twice Imagine a company with 500 million billing history rows sitting in Snowflake. The Old Way: Data engineers build a complex pipeline to ingest all 500 million rows into Salesforce. The company pays to store the massive dataset twice. They then spend months babysitting the pipeline to ensure both copies stay perfectly in sync. Meanwhile, the data warehouse team views Salesforce as a competitor duplicating their hard work. The Zero-Copy Way: You simply point Salesforce Data Cloud at the existing Snowflake table. The data is queried in place and dynamically joined ...
Read article
Data 360

Salesforce Privacy Data Model & Consent API: Architecting for GDPR & CCPA

💬 In plain words: The consent layer in Salesforce consists of the Privacy Data Model combined with the Consent API. Together, they tie privacy permissions directly to the individual. By centralizing how you read and write permissions, "May we email this person?" stops being a guess or a messy custom field check, and becomes a strict, auditable data query that your segmentation and activation engines automatically respect. 📌 Real-Life Example: A customer texts "STOP" and files a GDPR deletion request. Using the Consent API, the system instantly flips their contact-point consent to opted-out. Tonight’s marketing segment automatically excludes them. Meanwhile, the erasure request triggers a deletion flow that purges their unified profile across the system. Consent is treated as structured data, not a sticky note.
Read article
Apex Development

Salesforce @future Methods vs. Queueable: The Modern Guide

💬 In plain words: The @future annotation is the original "fire-and-forget" asynchronous tool in Salesforce. You tag a static method, and the platform runs it later. However, its strict limitations—only accepting primitive data types, no ability to chain jobs, and no traceable Job ID—are the exact reasons Queueable Apex was created to replace it. Today, @future is mainly used as a quick escape hatch for Mixed-DML errors. 📌 The Problem: In legacy code, a trigger might call @future(callout=true) to push data to an external ERP. It works fine until a developer tries to trigger that same logic from a Batch Apex job, resulting in the dreaded error: "future method cannot be called from a future or batch method." The Fix: The modern solution is to rewrite that logic as a Queueable class, leaving @future purely for resolving quick Setup vs. Non-Setup object conflicts (Mixed-DML). 🎬 Real-Life Example: The Stale Snaps...
Read article
Apex Development

Salesforce Sync vs. Async Apex: How to Choose the Right Path

💬 In plain words: Synchronous (Sync) means the user waits for the process to finish, and you are constrained by tight platform limits. Asynchronous (Async) means the work happens later in the background, giving you much higher limits. Move work to async when it is slow (like API callouts or heavy calculations) or involves massive amounts of data. However, remember that async means "eventually." Do not use it if the user needs to see the result immediately on their screen. 📌 Real-Life Example: A user clicks "Save" on an order. You need to update the Salesforce record NOW (sync). But do you also need to notify your SAP system and recalculate the customer's yearly totals instantly? No. The user shouldn't have to stare at a loading spinner waiting for SAP to respond. Publish an event and queue the recalculation in the background. Think of sync as the fast lane for the user, and async as the freight lane for the heavy lifting. ...
Read article
Salesforce Basics

Salesforce Trigger Frameworks: Bulkification & Reentrancy Explained

⚡ 1-Minute Summary: Shared Transaction Budget: Salesforce governor limits apply across an entire execution transaction, shared by your Apex triggers, Record-Triggered Flows, validation rules, and installed managed packages. One Trigger Per Object: Keep the trigger file completely free of business logic, dispatch work to a structured handler class, and build an admin-controlled bypass switch on day one. Default Async Choice: Use Queueable Apex as your standard asynchronous tool for chaining, non-primitive parameters, and job monitoring rather than writing new @future methods.
Read article
Topic Agentforce
Agentforce

Mastering Subagent Architecture in Salesforce Agentforce: Avoiding Description Overlaps and Ceiling Limits

In plain words: In Salesforce Agentforce, a subagent (called a Topic in earlier Agent Builder releases) is a specialized unit built to handle one distinct category of user requests. Because the entry Agent Router ( start_agent ) decides where to send each message by reading subagent description fields before looking at any internal instructions or actions, overlapping subagent descriptions are the primary cause of inconsistent routing and wrong agent responses. When an AI agent behaves erratically—answering a question accurately on Monday and failing on a nearly identical prompt on Tuesday—the root cause is rarely random model hallucination. Instead, the agent usually suffers from description overlap . When two or more subagents claim responsibility for similar user intents, the router is forced to guess which subagent should take the turn. Even worse, because every subagent is backed by a capable language model, the wrong subagent will often generate a polite, pla...
Read article