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:
- Complete, working code
- Context and use cases
- Explanation of patterns
- Test examples
- Related pattern references
Apex Examples
Apex code examples demonstrating service layer, domain layer, selector layer, triggers, and asynchronous patterns.
Service Layer
- Service Layer Examples - Service layer pattern implementations with orchestration and delegation
Domain Layer
- Domain Layer Examples - Domain layer pattern implementations with business logic and validation
Selector Layer
- Selector Layer Examples - Selector layer pattern implementations with SOQL queries and security enforcement
Triggers
- Trigger Examples - Trigger handler patterns with bulkification and error handling
Asynchronous Patterns
- Queueable Examples - Queueable Apex implementations for asynchronous processing
- Batch Examples - Batch Apex implementations for large data processing
- Scheduled Examples - Scheduled Apex implementations for time-based automation
Integration Layer
- Integration Examples - Apex integration layer patterns with callouts and error handling
Related Patterns:
- Apex Patterns - Apex design patterns and best practices
- Asynchronous Apex Patterns - Asynchronous processing patterns
Lightning Web Component (LWC) Examples
Lightning Web Component examples demonstrating component patterns, wire services, and testing.
Components
- Component Examples - LWC component implementations with data binding and event handling
Wire Services
- Wire Examples - LWC wire service patterns with Lightning Data Service
Services
- Service Examples - LWC service layer patterns for data access and business logic
Testing
- Test Examples - Jest test examples for LWC components
Accessibility
- Accessibility Examples - Accessible LWC component patterns
Related Patterns:
- LWC Patterns - Lightning Web Component patterns and best practices
- LWC Best Practices - Official LWC best practices
Flow Examples
Flow examples demonstrating record-triggered flows, screen flows, and subflows.
Record-Triggered Flows
- Record-Triggered Flow Examples - Record-triggered flow patterns for automation
Screen Flows
- Screen Flow Examples - Screen flow patterns for user interactions
Subflows
- Subflow Examples - Subflow patterns for reusable automation logic
Related Patterns:
- Flow Patterns - Flow design and orchestration patterns
Integration Examples
Integration examples demonstrating REST APIs, Platform Events, callouts, CDC, and Bulk API patterns.
REST API
- REST API Examples - REST API integration patterns with outbound and inbound services
Platform Events
- Platform Events Examples - Platform Events patterns for event-driven architecture
Callouts
- Callout Examples - HTTP callout patterns with error handling and retries
Change Data Capture (CDC)
- CDC Examples - Change Data Capture patterns for real-time data synchronization
Bulk API
- Bulk API Examples - Bulk API patterns for large data operations
Related Patterns:
- Integration Platform Patterns - Integration platform patterns
- Callout Best Practices - Callout best practices
- Event-Driven Architecture - Event-driven architecture patterns
Utility Examples
Utility examples demonstrating logging, error handling, validation, custom settings, custom metadata, data migration, metadata API, and SFDX patterns.
Logging
- Logging Examples - Logging utility patterns for error tracking and debugging
Error Handling
- Error Handling Examples - Error handling patterns with custom exceptions and logging
Validation
- Validation Examples - Validation utility patterns for data quality
Custom Settings
- Custom Settings Examples - Custom Settings patterns for configuration management
Custom Metadata
- Custom Metadata Examples - Custom Metadata patterns for metadata-driven configuration
Data Migration
- Data Migration Examples - Data migration patterns for bulk data operations
Metadata API
- Metadata API Examples - Metadata API patterns for programmatic metadata management
SFDX
- SFDX Examples - Salesforce CLI (SFDX) patterns for development workflows
Related Patterns:
- Error Handling and Logging - Error handling and logging patterns
- Custom Settings and Metadata Patterns - Custom settings and metadata patterns
- SFDX Patterns - Salesforce CLI patterns
Templates
Code templates for common patterns and structures.
Apex Templates
- Service Template - Service layer class template
- Domain Template - Domain layer class template
- Selector Template - Selector layer class template
- Trigger Template - Trigger handler template
- Queueable Template - Queueable Apex template
- Batch Template - Batch Apex template
- Scheduled Template - Scheduled Apex template
Testing Templates
- Test Class Template - Apex test class template
LWC Templates
- Accessible Component Template - Accessible LWC component template
Project Templates
- SFDX Project Template - Salesforce DX project structure template
- CI/CD Template - CI/CD pipeline configuration template
Usage
For Developers
- Find Examples: Browse by category to find relevant examples
- Copy Code: All examples are copy-paste ready
- Follow Patterns: Examples demonstrate best practices and patterns
- Read Context: Each example includes use cases and explanations
- Run Tests: Test examples are included for validation
For RAG Systems
- Metadata: All examples include frontmatter with tags and descriptions
- Cross-References: Examples link to related patterns
- Context: Examples include “when to use” and “what problem it solves”
- Complete Code: Examples are complete and working, not pseudocode
Related Resources
- RAG Knowledge Library Index - Complete index of all knowledge files
- Apex Patterns - Apex design patterns
- LWC Patterns - Lightning Web Component patterns
- Flow Patterns - Flow design patterns
- Integration Patterns - Integration platform patterns