Code Examples Index

Complete, working code examples organized by category. All examples are copy-paste ready and follow Salesforce best practices.

Overview

This index provides access to all code examples in the repository, organized by domain and type. Each example includes:

Apex Examples

Apex code examples demonstrating service layer, domain layer, selector layer, triggers, and asynchronous patterns.

Service Layer

Domain Layer

Selector Layer

Triggers

Asynchronous Patterns

Integration Layer

Related Patterns:

Lightning Web Component (LWC) Examples

Lightning Web Component examples demonstrating component patterns, wire services, and testing.

Components

Wire Services

Services

Testing

Accessibility

Related Patterns:

Flow Examples

Flow examples demonstrating record-triggered flows, screen flows, and subflows.

Record-Triggered Flows

Screen Flows

Subflows

Related Patterns:

Integration Examples

Integration examples demonstrating REST APIs, Platform Events, callouts, CDC, and Bulk API patterns.

REST API

Platform Events

Callouts

Change Data Capture (CDC)

Bulk API

Related Patterns:

Utility Examples

Utility examples demonstrating logging, error handling, validation, custom settings, custom metadata, data migration, metadata API, and SFDX patterns.

Logging

Error Handling

Validation

Custom Settings

Custom Metadata

Data Migration

Metadata API

SFDX

Related Patterns:

Templates

Code templates for common patterns and structures.

Apex Templates

Testing Templates

LWC Templates

Project Templates

Usage

For Developers

  1. Find Examples: Browse by category to find relevant examples
  2. Copy Code: All examples are copy-paste ready
  3. Follow Patterns: Examples demonstrate best practices and patterns
  4. Read Context: Each example includes use cases and explanations
  5. Run Tests: Test examples are included for validation

For RAG Systems

  1. Metadata: All examples include frontmatter with tags and descriptions
  2. Cross-References: Examples link to related patterns
  3. Context: Examples include “when to use” and “what problem it solves”
  4. Complete Code: Examples are complete and working, not pseudocode