Tuesday, June 30, 2026

LWC: Reusable Donut / Pie Chart Component

🍩 Reusable Donut / Pie Chart Component for Salesforce LWC

A fully reusable SVG-based Lightning Web Component that renders beautiful, interactive Donut and Pie Charts using pure SVG with zero external JavaScript libraries.

📖 Project Overview

The Donut / Pie Chart Component is a reusable Lightning Web Component built entirely with native Salesforce technologies. It renders interactive charts using pure SVG, supports Apex-powered dynamic data as well as static datasets, and provides configurable legends, animated slices, hover tooltips, accessibility support, and responsive layouts.

Unlike third-party charting libraries, this solution requires zero external dependencies, making deployment simple while maintaining excellent performance and Lightning compatibility.

✨ Key Features

Feature Description
Pure SVG RenderingNo Canvas or third-party chart libraries required.
Donut & Pie ModesSwitch between Donut and Pie using a single property.
Animated SlicesHovered slices expand while remaining slices fade.
Interactive TooltipsDisplays label, value, and percentage on hover.
Configurable LegendSupports stacked and side-by-side layouts.
Dynamic Apex DataAutomatically loads data using Apex Wire.
Static Data SupportAccepts custom chart data from parent components.
Responsive LayoutAutomatically adapts to desktop and mobile screens.
AccessibilityKeyboard navigation, ARIA labels and focus support.
Loading & Error StatesBuilt-in loading, empty data and error handling.

🏗 Component Architecture

Donut Chart - LWC Component Architecture

📁 Project Structure

force-app
└── main
    └── default
        ├── classes
        │   └── DonutChartController.cls
        │
        └── lwc
            └── donutChart
                ├── donutChart.html
                ├── donutChart.js
                ├── donutChart.css
                └── donutChart.js-meta.xml

⚙️ Public API Properties

Property Purpose
titleChart title displayed above the component.
chartTypeChoose between donut or pie.
chartDataStatic chart data supplied by parent LWC.
recordIdAutomatically loads Apex data.
colorPaletteCustom array of chart colors.
showLegendDisplay chart legend.
legendPositionStacked or Side-by-Side layout.
showCenterTextDisplay total value inside the donut.
valuePrefix / valueSuffixFormat displayed values.

💻 Usage Example

<c-donut-chart
    title="Revenue by Stage"
    chart-type="donut"
    show-legend
    legend-position="side-by-side"
    show-center-text
    center-label="Total"
    value-prefix="$"
    chart-data={opportunityData}>
</c-donut-chart>

📊 Supported Features

  • Donut Charts
  • Pie Charts
  • Static Data
  • Apex Wire Data
  • Hover Animation
  • Keyboard Navigation
  • ARIA Accessibility
  • Responsive Layout
  • Custom Color Palette
  • Legend Totals
  • Loading State
  • Error State
  • Empty Data State

🎨 Customisation Options

✔ Custom Color Palette

✔ Legend Title

✔ Legend Position

✔ Center Label

✔ Value Prefix

✔ Value Suffix

✔ Label Field Mapping

✔ Value Field Mapping

✔ Donut / Pie Mode

♿ Accessibility

  • Keyboard accessible slices.
  • Tab navigation support.
  • Meaningful ARIA labels.
  • Screen reader friendly.
  • High contrast compatible.
  • Mobile responsive layout.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

🎯 Business Use Cases

  • Sales Pipeline Distribution
  • Opportunity Stage Analysis
  • Case Status Dashboard
  • Lead Source Analytics
  • Revenue Breakdown
  • Account Segmentation
  • Executive Dashboards
  • Service Performance Reports
  • Custom CRM Analytics

📌 Conclusion

The Reusable Donut / Pie Chart Component provides a lightweight, modern, and highly configurable visualization solution for Salesforce Lightning applications. Built entirely with native SVG, Lightning Web Components, and Apex, it delivers interactive charts without relying on external JavaScript libraries, making it ideal for enterprise Salesforce projects that require performance, accessibility, and easy customization.

Monday, June 29, 2026

LWC: Scheduled Job Monitor

⏰ Scheduled Job Monitor for Salesforce LWC

Monitor, manage, and analyze Salesforce Scheduled Apex Jobs directly from Lightning Experience with a modern reusable Lightning Web Component.

📖 Project Overview

Scheduled Job Monitor is a reusable Lightning Web Component that provides administrators and developers with a centralized dashboard for monitoring Salesforce Scheduled Apex Jobs.

Instead of navigating through Salesforce Setup pages, users can view scheduled jobs, inspect execution details, monitor upcoming schedules, abort running jobs, refresh data, search jobs, and analyze execution status directly from Lightning Experience.

The solution is built using Lightning Web Components, Apex, and Salesforce CronTrigger APIs while following Salesforce security best practices.

✨ Key Features

Feature Description
Scheduled Job Dashboard View all scheduled Apex jobs from a single Lightning page.
Real-Time Refresh Reload latest job information without leaving the page.
Search Jobs Quickly locate scheduled jobs by name.
Status Monitoring Track Waiting, Acquired, Executing, Complete, Error and Deleted jobs.
Abort Scheduled Jobs Cancel scheduled jobs directly from Lightning.
Execution Details Display next execution time, previous execution and schedule information.
Toast Notifications Success and error messages for all operations.
Responsive Design Works across desktop and tablet Lightning Experience.

🏗 Solution Architecture

Scheduled Job Monitor Architecture

📁 Project Structure

force-app
└── main
    └── default
        ├── classes
        │   ├── ScheduledJobMonitorController.cls
        │   └── ScheduledJobMonitorControllerTest.cls
        │
        ├── lwc
        │   └── scheduledJobMonitor
        │       ├── scheduledJobMonitor.html
        │       ├── scheduledJobMonitor.js
        │       ├── scheduledJobMonitor.css
        │       └── scheduledJobMonitor.js-meta.xml
        │
        └── permissionsets
            └── ScheduledJobMonitor.permissionset-meta.xml

⚙️ Dashboard Information

Column Description
Job NameScheduled Apex class name.
StateCurrent execution status.
Cron ExpressionComplete scheduling expression.
Next Fire TimeNext scheduled execution.
Previous Fire TimeLast successful execution.
Times TriggeredExecution count.
ActionsAbort and refresh operations.

🔄 Monitoring Workflow

Load Dashboard
      │
      ▼
Retrieve CronTrigger Records
      │
      ▼
Display Scheduled Jobs
      │
      ▼
Search / Filter Jobs
      │
      ▼
Review Execution Details
      │
      ▼
Abort Job (Optional)
      │
      ▼
Refresh Dashboard

📊 Supported Job States

WAITING
ACQUIRED
EXECUTING
COMPLETE
ERROR
DELETED

🔒 Security

  • Uses with sharing Apex controllers.
  • Supports Salesforce CRUD and Field-Level Security.
  • Respects user permissions while displaying scheduled jobs.
  • Permission Set included for easy deployment.
  • Native Salesforce scheduler APIs used without external integrations.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

sf org assign permset \
--name ScheduledJobMonitor

sf apex run test \
--class-names ScheduledJobMonitorControllerTest

🎯 Business Benefits

  • Eliminates navigation to Salesforce Setup.
  • Provides centralized scheduled job monitoring.
  • Improves administrator productivity.
  • Quickly identifies failed or inactive jobs.
  • Supports one-click job cancellation.
  • Reusable across multiple Salesforce organizations.
  • Modern Lightning user experience.

📌 Conclusion

The Scheduled Job Monitor provides Salesforce administrators and developers with a simple yet powerful interface for managing Scheduled Apex Jobs. By combining Lightning Web Components, Apex, and Salesforce scheduling APIs, the solution delivers real-time visibility into scheduled processes while simplifying monitoring and administration from within Lightning Experience.

Sunday, June 28, 2026

LWC: PDF Generator Button

📄 PDF Generator Button for Salesforce LWC

Generate professional PDF documents from any Salesforce record with a single click, automatically save them as Salesforce Files, and maintain a complete PDF history.

📖 Project Overview

PDF Generator Button is a reusable Lightning Web Component that enables users to generate PDF documents directly from Salesforce record pages.

The component renders a configurable Visualforce page as a PDF, stores it as a Salesforce File (ContentVersion), automatically links it back to the source record, and displays recently generated PDFs for quick access.

Designed for enterprise Salesforce applications, the solution works across standard and custom objects without requiring object-specific code.

✨ Key Features

Feature Description
One-Click PDF GenerationGenerate PDFs directly from Lightning record pages.
Reusable Across ObjectsSupports Account, Contact, Opportunity and custom objects.
Automatic File NamingCreates descriptive file names automatically or allows a custom name.
Salesforce Files IntegrationCreates ContentVersion and ContentDocumentLink records automatically.
PDF HistoryDisplays the latest generated PDFs for each record.
Download SupportOpen or download generated PDFs directly.
Toast NotificationsInstant success and error feedback.
Configurable TemplateUse any Visualforce page as the PDF template.
Permission Set IncludedEasy deployment using the included permission set.

🏗 Architecture

PDF Generator LWC Architecture Diagram

📁 Project Structure

force-app/main/default
│
├── lwc
│   └── pdfGeneratorButton
│       ├── pdfGeneratorButton.html
│       ├── pdfGeneratorButton.js
│       ├── pdfGeneratorButton.css
│       └── pdfGeneratorButton.js-meta.xml
│
├── classes
│   ├── PdfGeneratorController.cls
│   ├── PdfGeneratorControllerTest.cls
│   ├── RecordPdfPageController.cls
│   └── RecordPdfPageControllerTest.cls
│
├── pages
│   └── RecordPdfPage.page
│
└── permissionsets
    └── PdfGenerator.permissionset-meta.xml

⚙️ Lightning App Builder Configuration

Property Default Description
buttonLabel Generate PDF Custom label displayed on the button.
vfPageName RecordPdfPage Visualforce page used to generate the PDF.
pdfFileName Auto Generated Optional static PDF filename.

🔄 PDF Generation Flow

Open Record
      │
      ▼
Click "Generate PDF"
      │
      ▼
Visualforce Page Rendered
      │
      ▼
PDF Created
      │
      ▼
ContentVersion Created
      │
      ▼
ContentDocument Linked
      │
      ▼
PDF History Refreshed

📂 Automatic File Naming

__.pdf

Example:

Account_001XXXXXXXXXXXX_2026-06-28.pdf

📜 PDF History

  • Displays the latest 20 generated PDF files.
  • Shows files linked to the current record.
  • One-click preview and download.
  • Automatically refreshes after generating a new PDF.

🧩 Custom PDF Templates

The component supports any Visualforce page as a PDF template. Simply specify the Visualforce page API name in the component configuration to generate customized invoices, quotations, certificates, reports, contracts, or business documents.

🔐 Security Features

  • Uses with sharing Apex controllers.
  • Respects Salesforce record-level security.
  • Stores documents using native Salesforce Files.
  • Supports controlled rollout through the included permission set.
  • Works with standard Salesforce authentication.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

sf org assign permset \
--name PdfGenerator

sf apex run test \
--class-names PdfGeneratorControllerTest,RecordPdfPageControllerTest

🎯 Business Use Cases

  • Invoice Generation
  • Sales Quotations
  • Customer Agreements
  • Booking Confirmations
  • Service Reports
  • Purchase Orders
  • Certificates
  • Inspection Reports
  • Healthcare Documents
  • Custom Business Forms

📌 Conclusion

The PDF Generator Button is a reusable Salesforce Lightning Web Component that streamlines PDF creation directly from Lightning record pages. By combining Lightning Web Components, Apex, Visualforce, and Salesforce Files, it provides a simple, secure, and scalable solution for generating and managing business documents across any Salesforce object.