Skip to main content

visualforce

Explore practical guides and implementation patterns for this topic.

Posts

Lightning Web Components

Mastering the Salesforce UI Layer: LWC vs. Aura vs. Visualforce & Dynamic Forms

💬 In Plain Words: Salesforce has three generations of UI frameworks. Visualforce is the oldest (page-per-server-trip). Aura was the first component-based framework, but it is slow and heavy. Lightning Web Components (LWC) is the modern web standard and is vastly faster. The rule today is simple: All new custom development must be LWC. For declarative (no-code) development, use Lightning App Builder to assemble pages, and Dynamic Forms to put fields conditionally on a page without writing code. 📌 The Strategy Example: Imagine your org has a 2014 Visualforce quote PDF, complex Aura components built in 2018, and a brand new business requirement. The Verdict: Keep the Visualforce page (it's still the best engine for rendering PDFs). Leave the working Aura components alone, but freeze them (no new features). Build the new business requirement entirely in LWC. UI migration is a roadmap, not a reckless rewrite.
Read article
Apex Development

How to Upload and Insert CSV Data into Salesforce Using Visualforce and Apex

Importing data in bulk from a local spreadsheet is a standard requirement for many enterprise applications. While tools like Data Loader handle this out of the box, developers often need to build custom, self-service tools that allow end-users to upload and process CSV files directly from a custom page layout. In plain words: You can create a file upload interface using Visualforce, capture the file content as a binary blob, and use an Apex controller to parse the text data line-by-line. The code converts those text rows into Salesforce objects (like Contact records) and inserts them into the database in bulk.
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

While Lightning Web Components (LWC) are the modern standard for Salesforce UI development, thousands of organizations still maintain and build upon complex Visualforce pages for internal data-entry tools. One of the most common—and challenging—requirements is creating a single, unified screen where users can dynamically add multiple parent records (like Accounts) and multiple child records (like Contacts) at the same time before hitting save. In plain words: To let users click an "Add Row" button for both parent and child records on a single Visualforce page, you must use "nested wrapper classes" in your Apex controller. These wrappers tie the records together in the server's memory, so when the user adds or deletes a specific row, Salesforce knows exactly which data to update without losing their inputs.
Read article
Topic Apex
Apex Development

How to Pass JavaScript Variables to Apex in Visualforce Using apex:actionFunction

While Lightning Web Components (LWC) are the modern standard for Salesforce development, thousands of organizations still rely on Visualforce pages for complex, legacy internal tools. One of the most common challenges developers face when maintaining these pages is figuring out how to pass dynamic values from the client-side (JavaScript) directly to the server-side (Apex controller). The cleanest and most reliable way to bridge this gap in Visualforce is by utilizing the <apex:actionFunction> component paired with <apex:param> tags. In plain words: An <apex:actionFunction> component automatically generates a JavaScript function on your page. When you call this function in your script, it silently triggers an asynchronous AJAX request to your Apex controller, allowing you to pass front-end variables directly into your backend code without refreshing the page.
Read article
Apex Development

How to Build Pagination in Salesforce Using StandardSetController and Wrapper Classes

💬 In plain words: Pagination breaks massive lists of Salesforce records into smaller, clickable pages (like Page 1, 2, 3). By combining Salesforce's built-in StandardSetController (which handles the math for "Next" and "Previous" pages) with a custom Wrapper Class , you can display these smaller lists while letting users check boxes next to rows to perform bulk actions. Displaying hundreds or thousands of records on a single page causes slow load times, high memory consumption, and a terrible user experience. Furthermore, standard Salesforce sObjects (like Account ) do not have a built-in "isSelected" checkbox field for the UI. To solve both problems simultaneously, we pair the ApexPages.StandardSetController with a custom Apex Wrapper Class.
Read article
Topic LWC
Lightning Web Components

Title: How to Embed Visualforce in LWC with Two-Way Communication

While Lightning Web Components (LWC) represent modern Salesforce frontend development, legacy application features, complex PDF generation engines, or third-party libraries often still rely on standard Visualforce pages. Fortunately, you can embed legacy Visualforce pages inside an LWC iframe and establish smooth, bidirectional communication using standard Web APIs. In plain words: You can embed a Visualforce page inside an LWC using an <iframe> element and share real-time data back and forth using the browser's native JavaScript window.postMessage() method.
Read article
Lightning Web Components

How to Generate, Preview, Save & Email Custom Quote PDFs in Salesforce (Apex & LWC Guide)

In plain words: Salesforce provides standard template buttons to create Quote PDFs, but they have layout limitations. By combining a custom Visualforce PDF template with an Apex controller and a Lightning Quick Action, you can preview customized quotation layouts, save the binary document directly to the Quote's related list, and email the PDF attachment to the client in a single click. While standard Salesforce Quote templates cover basic invoicing, enterprise organizations frequently require custom branding, complex table calculations, custom terms, and automated emailing. Building a custom Quote PDF engine allows you to generate high-fidelity PDF documents, store them under the QuoteDocument object, and deliver them to customers without third-party document generation apps.
Read article
Topic Apex
Apex Development

Build a Project Metadata & Schema Audit Dashboard in Salesforce (Apex & Visualforce)

In plain words: A Project Component Dashboard gives developers and release managers a single-screen inventory of everything inside a project or namespace—including Custom Objects, Permission Sets, Apex Classes, Visualforce Pages, Triggers, and Entity Relationships—without navigating through dozens of Setup menus. During release preparation, package maintenance, or technical documentation audits, development teams need a fast way to map all components associated with a specific project or managed namespace. By combining Dynamic Apex Schema Describe with SOQL queries against system metadata tables ( ApexClass , ApexPage , EntityDefinition , and ObjectPermissions ), you can render a real-time inventory dashboard styled with the Salesforce Lightning Design System (SLDS).
Read article
Topic Life Sciences
Life Sciences

Integrating Veeva Vault with Salesforce: OAuth 2.0, Apex REST & Architecture Guide

In plain words: Integrating Veeva Vault with Salesforce connects a life sciences regulatory content management system directly to your CRM. By authorizing Salesforce via OAuth 2.0 and making secure Apex REST callouts, pharmaceutical and biotech teams can search, preview, and link compliant medical documents, clinical trial data, and approved promotional materials without leaving Salesforce. In life sciences and pharmaceutical organizations, managing regulated content requires strict adherence to global health authority standards (such as FDA 21 CFR Part 11). While Veeva Vault serves as the validated repository for clinical, regulatory, and commercial documentation, field teams operate daily inside Salesforce CRM and Life Sciences Cloud . Building a secure, programmatic bridge between these platforms streamlines access to approved collateral and maintains a synchronized regulatory audit trail.
Read article
Topic Apex Controller Best Practices Dynamic UI Lightning Web Components Salesforce Development Survey Forms visualforce
Apex Controller Best Practices Dynamic UI Lightning Web Components Salesforce Development Survey Forms visualforce

Dynamic Question-Answer UI in Salesforce: Visualforce, Apex & Modern LWC Patterns

In plain words: A Dynamic Question-Answer UI generates intake forms, questionnaires, or audits dynamically from database records or metadata rather than hardcoding static form fields. In Salesforce, this is achieved by combining an Apex controller (which manages the questions, answers, and data models) with a dynamic UI template (like Visualforce or Lightning Web Components) to capture user input seamlessly. Standard static pages fail when business requirements demand configurable questionnaires, dynamic intake audits, or interactive customer surveys. When questions frequently change or depend on user selections, hardcoding fields directly into a page requires continuous code deployments. Building a data-driven, dynamic question-and-answer architecture allows administrators to add or alter questions while the user interface renders the input controls automatically.
Read article
Topic Apex Wrapper Hierarchical Data Lightning Web Components lightning-tree-grid Salesforce Development Tree View UI Design visualforce
Apex Wrapper Hierarchical Data Lightning Web Components lightning-tree-grid Salesforce Development Tree View UI Design visualforce

Building Hierarchical Tree Views in Salesforce: Visualforce, Apex & Modern LWC Guide

In plain words: A Tree View is a collapsible, hierarchical display that shows parent-child relationships between records—such as Corporate Accounts and their Child Subsidiaries, or Roles and Subordinates. In Salesforce, you construct tree views by structuring data using recursive Apex wrapper classes and rendering them with clean CSS in Visualforce or using native <lightning-tree-grid> components in modern Lightning Web Components (LWC). Standard Salesforce record lists display flat tables, making it difficult for users to visualize nested business relationships. Complex enterprise hierarchies—such as parent-child account trees, multi-level product bundles, or department role trees—require an intuitive, expandable node structure. Building custom tree views helps users navigate data relationships quickly without opening dozens of separate browser tabs.
Read article
Topic Apex Controller CSS Styling PDF Generation renderAs="pdf" Salesforce Development Salesforce Limits visualforce
Apex Controller CSS Styling PDF Generation renderAs="pdf" Salesforce Development Salesforce Limits visualforce

How to Generate Attractive PDF Files Using Visualforce in Salesforce

In plain words: You can turn any Salesforce data into a downloadable PDF document (like invoices, quotes, or customer reports) using Visualforce. By simply adding renderAs="pdf" to your <apex:page> tag and applying standard CSS, Salesforce's rendering engine automatically converts the HTML into a formatted PDF file. Generating PDFs dynamically from CRM data is a common business requirement. Whether you need to generate professional quotes for clients, formatted invoices, or compliance reports, Visualforce remains the most reliable native tool in Salesforce for PDF generation. By combining standard Apex controllers with standard HTML and CSS, you can create pixel-perfect documents.
Read article
Topic Apex
Apex Development

Mastering Visualforce View State in Salesforce: Limits & Optimization

In plain words: View State in Salesforce is a hidden, encrypted data package passed back and forth between your browser and Salesforce servers. It remembers your Visualforce page's state (like form inputs and variables) across page refreshes or button clicks. Salesforce enforces a strict maximum limit of 170 KB for this data. If you exceed it, your page will crash with a fatal runtime error. When you build custom Visualforce apps with interactive forms, search filters, or data tables, maintaining information across server requests is crucial. Because standard web traffic doesn't naturally "remember" things, Salesforce uses View State to track your Apex controller variables and component details. If you aren't careful with how much data you store, your page weight will bloat rapidly, leading to slow performance and crashed pages.
Read article
Topic LWC
Lightning Web Components

How to Build a Custom Visualforce Data Table with Pagination in Salesforce

In plain words: Data Table Pagination divides massive Salesforce datasets into bite-sized, sequential pages (e.g., 10 or 25 records per view). Instead of pulling thousands of records into the browser at once—which slows down the page and triggers the 170 KB Visualforce view state limit—pagination fetches only the current page's records on demand using server-side Apex queries or the StandardSetController . Displaying large datasets in Salesforce without pagination degrades page responsiveness and risks hitting platform limits. Querying thousands of records at once blows past the 50,000 SOQL row retrieval limit, inflates Visualforce View State beyond 170 KB, and creates a frustrating user experience. Implementing structured pagination in Apex and Visualforce gives users fast, predictable navigation while keeping platform resource consumption minimal.
Read article
Topic LWC
Lightning Web Components

How to Communicate Between LWC and Visualforce in Salesforce: Complete Integration Guide

In plain words: LWC and Visualforce Integration allows modern Lightning Web Components to trigger actions and exchange data with legacy Visualforce pages (such as custom PDF generators or legacy rendering engines). Rather than popping open disconnected browser tabs, you can embed the Visualforce page in an <iframe> and communicate bi-directionally using window.postMessage or publish/subscribe across the DOM using Lightning Message Service (LMS) . While Lightning Web Components (LWC) is the primary UI framework on Salesforce, enterprise orgs frequently maintain complex Visualforce pages for specialized features like rendering dynamic PDFs ( renderAs="pdf" ) or hosting third-party canvas applications. Connecting these two technologies seamlessly without disrupting the user experience requires secure, cross-window messaging channels.
Read article
Topic LWC
Lightning Web Components

How to Call LWC Methods from Visualforce in Salesforce: Lightning Out & LMS Guide

In plain words: Calling an LWC method from a Visualforce page allows legacy Visualforce layouts to trigger actions inside modern Lightning Web Components. Because Visualforce and LWC run on different runtime engines, communication is handled on the client side using Lightning Out with public @api methods or by publishing events across the platform using Lightning Message Service (LMS) . During digital transformation projects, organizations rarely replace entire Visualforce applications overnight. Instead, developers embed modern Lightning Web Components inside existing Visualforce pages. To make these hybrid pages interactive, your Visualforce JavaScript must be able to invoke functions and pass data directly into the hosted LWC.
Read article
Topic Apex
Apex Development

How to Build a Custom Multi-Object Search in Salesforce Using SOSL and Visualforce

In plain words: SOSL (Salesforce Object Search Language) is a search language designed to scan text across multiple unrelated standard and custom objects in a single query, returning separate lists of matching records efficiently. While SOQL queries individual database tables with exact field matching, SOSL indexes text fields across your entire org. Pairing SOSL with a custom Visualforce or Lightning interface allows developers to create unified global search panels tailored to custom business workflows.
Read article
Topic Apex
Apex Development

How to Add jQuery DataTables to Visualforce: Pagination, Search & Sorting Guide

Displaying large datasets in Salesforce Visualforce pages using standard tables can quickly lead to slow page loads, messy interfaces, and limited user controls. Integrating the lightweight jQuery DataTables plugin turns standard HTML tables into dynamic data grids complete with instant search, multi-column sorting, and responsive pagination. In plain words: jQuery DataTables is a drop-in JavaScript library that enhances basic HTML tables with out-of-the-box client-side pagination, instant keyword filtering, and column sorting without reloading the page.
Read article
Apex Component Frontend Design Lightning Design System Salesforce SLDS UI Development visualforce

How to Build a Dynamic SLDS Path Component in Salesforce Visualforce

Showing progress helps users see where a record stands at a glance. Lightning record pages have the standard Path component, but custom Visualforce pages don't get it for free. With the Salesforce Lightning Design System (SLDS) , you can build two kinds of progress indicators in Visualforce that match the Lightning look: a progress bar and a path . In plain words: A progress bar is a horizontal meter that fills from 0% to 100% as a record moves forward. A path is a row of chevrons that shows each stage by name (like Draft → Submitted → In Review → Approved ) and marks which stages are done, which one is current, and which are still ahead. Both read the record's status field and update on their own.
Read article