I put together this complete Apex handbook as a single, go-to reference for every developer working within the Salesforce platform — whether you’re just setting up your first dev environment or designing enterprise-grade trigger frameworks. This page organizes all the Apex tutorials I’ve written into focused sections so you can navigate directly to what you need.
Apex is Salesforce’s strongly typed, object-oriented programming language built natively into the platform. It lets me — and you — execute custom business logic in response to system events, write complex data operations, build automation, and create rich user interfaces using Visualforce. Think of it as the engine behind every advanced Salesforce customization.
My goal with this Apex & Triggers Handbook is simple:
- If you are new to Apex, you can follow a clean learning path from basics to advanced topics.
- If you already write Apex, you can use this page as a reference for trigger patterns, async Apex, callouts, LWC integration, and error handling.
You can bookmark this page and treat it as your main Apex guide while working on Salesforce implementations.
Who this Salesforce Apex & Triggers guide is for
This guide is for you if:
- You are an Admin or Consultant moving from “clicks” (Flows) into “code” (Apex).
- You are a Developer who wants clear, practical Apex examples instead of only theory.
- You are an Architect who wants to standardize Apex patterns across multiple projects.
I will start with Apex fundamentals, then dive into triggers, async Apex, callouts, LWC integration, and finally error handling and best practices.
Setting Up Your Development Environment
Before writing a single line of Apex, you need a properly configured development environment. These tutorials walk you through connecting VS Code to your Salesforce org and resolving common setup issues that trip up most new developers.
Variables, Data Types & Type Conversions
Understanding data types and how to convert between them is foundational to writing reliable Apex code. I cover every major conversion scenario here — from strings to integers, dates, booleans, blobs, and more — so you always know exactly how to handle data in any context.
- Variables and Data Types in Salesforce Apex
- How to Convert a String to an Integer using Apex in Salesforce
- How to Convert String to Date in Salesforce Apex
- How to Convert String to ID in Salesforce Apex
- How to Convert String to Boolean in Salesforce Apex
- How to Convert a String to Decimal in Salesforce Apex
- How to Convert String to Blob in Salesforce Apex
- How to Convert String to Datetime in Salesforce Apex
- How to Convert String to Double in Salesforce Apex
- How to Convert String to sObject in Salesforce Apex
- How to Convert ID to String in Salesforce Apex
- How to Convert Integer Data Type to Decimal in Salesforce Apex
- How to Convert Integer Data Type to String in Salesforce Apex
- How to Convert Date to String in Salesforce Apex
- How to Convert DateTime to Date Format in Salesforce Apex
- How to Convert JSON to String in Salesforce Apex
- How to Convert a JSON String to a Map in Salesforce Apex
- How to Convert List to String in Salesforce Apex
- How to Convert TimeZone Values in Salesforce
- How to Get Current Datetime in Apex Salesforce
- How to Extract Year, Month, and Day from a Date Field in Salesforce Apex
- How to Compare Two DateTime Values in Salesforce Apex
- How to Add Days, Months, and Years to Date field in Salesforce Apex
String Operations & the String Class
The String class in Apex is one of the most used tools in any developer’s toolkit. I’ve documented every important method — from case conversion and splitting to null checks, character detection, and SOQL-based string queries — so you can handle any string manipulation scenario with confidence.
- String Class in Apex Salesforce: Complete Guide with Methods & Examples
- String Class Methods in Salesforce Apex
- Apex String Methods to Determine Character Types in Salesforce
- String SOQL Queries in Salesforce Apex
- Contains() Method in Salesforce Apex
- How to Convert String to Lowercase and Uppercase in Salesforce Apex
- How to Split String Method in Salesforce Apex
- How to Reverse a String in Salesforce Apex
- How to Replace String in Salesforce Apex
- How to Remove First and Last Character from a String in Salesforce Apex
- How to Check if a String is Null, Empty or Blank in Salesforce Apex
- How to Generate the Random String using Apex in Salesforce
- How to Truncate String in Salesforce Apex
Collections: List, Set & Map
Collections are at the heart of bulkified Apex code. In this section, I walk through how to create and work with Lists, Sets, and Maps — including how to convert between them — so you can write efficient, governor-limit-friendly logic that handles bulk data operations cleanly.
- Collections in Salesforce Apex: List, Set & Map Explained
- How to Create List Collection in Salesforce Apex
- How to Create Set Collection in Salesforce Apex
- How to Create Map Collection in Salesforce Apex
- Convert Apex List to Set and Map Collections in Salesforce
- How to Convert List to String in Salesforce Apex
- Custom Iterator Interface in Salesforce Apex
Control Flow, Loops & Operators
Writing clean, readable logic in Apex requires a solid understanding of control flow statements. Here, I cover every loop type, conditional structure, and operator — including some of the more powerful modern Apex features like the safe navigation operator and null coalescing operator.
- Loops in Salesforce Apex: For, While, Do-While Examples
- Logical and Looping Statements in Salesforce Apex Programming
- Salesforce Apex If Else, Nested If, and Switch Case Examples
- How to Use Switch Statement in Salesforce Apex
- Ternary Operator in Salesforce Apex
- Safe Navigation Operator in Salesforce Apex
- Null Coalescing Operator in Salesforce
- Create a For Loop to Iterate Through a SOQL Query
- Operators in Salesforce Apex
Object-Oriented Programming in Apex
Apex is a fully object-oriented language, and understanding its OOP principles unlocks cleaner, more maintainable architectures. I cover everything here — from classes and constructors, to inheritance, interfaces, polymorphism, abstraction, and advanced patterns like dependency injection.
- Object Oriented Programming in Salesforce Apex
- Inheritance in Salesforce Apex
- Interfaces in Salesforce Apex and How to Use It
- Polymorphism in Salesforce Apex
- Abstraction in Salesforce Apex
- Access Modifiers in Salesforce Apex Classes
- How to Create and Use Constructors in Salesforce Apex Classes
- Virtual Class in Salesforce Apex
- How to Create Wrapper Class in Salesforce Apex
- Dependency Injection in Salesforce Apex Class
- How to Create SObject in Salesforce Apex
- What is Schema Class in Salesforce Apex and How to Use It
- Salesforce Apex With, Without, Inherited and Omitted Sharing
- Exception Handling in Salesforce Apex
- Different Types of Exceptions in Salesforce Apex
- Display Custom Error Messages in Salesforce Apex
- Apex Classes in Salesforce [Essential Building Blocks for Custom Development]
- Compare two Strings in Salesforce Apex
- How to Convert Date to DateTime Format in Salesforce Apex
- How to Convert Decimal to Integer in Salesforce Apex
- How to Convert Unix Timestamp to DateTime using Apex in Salesforce
- How to Define and Use Constants in Salesforce Apex Classes
- How to Test Apex Classes Using Test Methods in Salesforce
- Serialize and Deserialize Enums in JSON in Salesforce Apex
SOQL: Salesforce Object Query Language
SOQL is how I retrieve data from Salesforce, and it has far more depth than most tutorials cover. This section is the most comprehensive reference I’ve built — covering every clause, operator, pattern, limit, and security consideration you’ll need in real-world development.
SOQL Fundamentals
- Salesforce Object Query Language (SOQL) in Apex
- SOQL Query in Apex Programming
- SOQL vs SQL Difference in Salesforce
- What is the Difference between SOQL and SOSL in Salesforce
- SOQL Governor Limits in Salesforce
- Salesforce SOQL and SOSL Limits for Search Queries
- System.LimitException: Too Many SOQL Queries
- Polymorphic Relationships in Salesforce SOQL (Complete Guide with Examples)