Apex Reference Guide
Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Salesforce Platform server, in conjunction with calls to the API. This reference guide includes built-in Apex classes, interfaces, enums, and exceptions, grouped by namespace. It also includes Apex DML statements to insert, update, merge, delete, and restore data in Salesforce.
For information on the Apex development process, see Apex Developer Guide.
In API version 51.0 and earlier, Apex Reference information was included in the Apex Developer Guide in the “Apex Language Reference” section.
Keep these guidelines in mind regarding API version usage:
- Salesforce strongly recommends that you use the latest available API version.
- If you can’t upgrade to the latest version yet, use API versions released in the past three years, for improved performance, security, and compatibility.
- To reduce complexity, consolidate your Apex codebase to use the minimal number of API versions, ideally, just one API version.
For a non-exhaustive list of major Apex behavior changes across API versions, organized by version number, see Apex Versioned Behavior Changes.
-
Use the Salesforce Release Notes to learn about the most recent updates and changes to Apex.
-
You can perform DML operations using the Apex DML statements or the methods of the
Databaseclass. For lead conversion, use theconvertLeadmethod of theDatabaseclass. There is no DML counterpart for it. -
The
ApexPagesnamespace provides classes used in Visualforce controllers. -
The
AppLaunchernamespace provides methods for managing the appearance of apps in the App Launcher, including their visibility and sort order. -
The
Approvalnamespace provides classes and methods for approval processes. -
The
Authnamespace provides an interface and classes for single sign-on into Salesforce and session security management. -
The
Cachenamespace contains methods for managing the platform cache. -
The
Canvasnamespace provides an interface and classes for canvas apps in Salesforce. -
The
ChatterAnswersnamespace provides an interface for creating Account records. -
The
CommerceBuyGrpnamespace provides classes and methods for retrieving information about the buyer groups associated with a user. -
Use the
CommerceExtensionnamespace to define resolution strategies for registered Commerce extensions. -
The
CommerceOrdersnamespace provides classes and methods to place orders with integrated pricing, configuration, and validation. -
Use the
CommercePaymentsnamespace to provide a safe and customizable platform for managing customer payments and refunds. -
Manage the communication between Salesforce and an external tax engine.
-
commonserviceexcellence Namespace
The
commonserviceexcellencenamespace provides classes used in financial account FlexCards. These classes are documented in the Agentforce Financial Services Developer Guide. -
The
ComplianceMgmtnamespace provides classes and methods to implement rule processors for compliance control. -
The Compression namespace provides classes and methods to create and extract zip files.
-
The
ConnectApinamespace (also called Connect in Apex) provides classes for accessing the same data available in Connect REST API. Use Connect in Apex to create custom experiences in Salesforce. -
The
Contextnamespace provides classes and methods to manage the sharing and consumption of business application data by using Context Service. -
The
Databasenamespace provides classes used with DML operations. -
The
Datacloudnamespace provides classes and methods for retrieving information about duplicate rules. Duplicate rules let you control whether and when users can save duplicate records within Salesforce. -
The
DataRetrievalnamespace provides classes and methods to record details of customer-agent engagements, as well as transcripts of their conversations. -
The
DataSourcenamespace provides the classes for the Apex Connector Framework. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Then connect your Salesforce organization to any data anywhere via the Salesforce Connect custom adapter. -
The DataWeave namespace provides classes and methods to support the invocation of DataWeave scripts from Apex.
-
The
Domnamespace provides classes and methods for parsing and creating XML content. -
The
embeddedainamespace provides classes and methods to manage and represent records and data in Apex to support embedded AI features. -
The
EventBusnamespace provides classes and methods for platform events and Change Data Capture events. -
The
ExternalServicenamespace provides dynamically generated Apex service interfaces and Apex classes for complex object data types. -
The
Flownamespace provides a class for advanced access to flows from Apex such as from Visualforce controllers and asynchronous Apex. -
The
flowtestingnamespace provides dynamically generated Apex classes for flow tests that are created in Flow Builder. -
The classes and methods in this namespace are reserved for internal use only or future use.
-
The FormulaEval namespace provides classes and methods to evaluate dynamic formulas for SObjects and Apex objects. Use the methods to avoid unnecessary DML statements to recalculate formula field values or evaluate dynamic formula expressions.
-
The
disputemanagementnamespace classes provide services for Integration Procedures used by the Transaction Dispute Management OmniScript. These classes are documented in the Agentforce Financial Services Developer Guide. -
The
fsccashflownamespace provides classes used in the FSCCashFlow FlexCards and their child FlexCards. These classes are documented in the Agentforce Financial Services developer guide. -
fsccomplaintmanagement Namespace
The
fsccomplaintmanagementnamespace classes provide data helper functions for use in complaint management. These classes are documented in the Agentforce Financial Services Developer Guide. -
The
fschouseholdnamespace provides classes used for households, financial accounts, goals, and plans. These classes are documented in the Agentforce Financial Services Developer Guide. -
The
fscserviceprocessesnamespace provides classes used in service process OmniScripts, such as change address and fee reversal. These classes are documented in the Agentforce Financial Services Developer Guide. -
The
fscwmgennamespace provides an interface and classes used for record alerts. These are documented in the Agentforce Financial Services Developer Guide. -
industriespersonalizedfinance Namespace
The
industriespersonalizedfinancenamespace classes provide data helper functions for use in personalized finance. These classes are documented in the Agentforce Financial Services Developer Guide. -
Functions Namespace
The Functions namespace provides classes and methods used to invoke and manage Salesforce Functions.
-
The ise_bots_apex namespace provides classes and properties to facilitate dynamic content generation and data handling for menu-driven bot interactions. Create and manage dynamic menu items that adapt to user inputs, context, and underlying object data.
-
The IssueCreditMemo namespace provides classes to create and apply credit memos against invoices or invoice lines based on dispute adjustments.
-
ind_mfg_sample_mgmt_apex Namespace
The ind_mfg_sample_mgmt_apex namespace provides classes and properties to manage the lifecycle and documentation of product requirements in manufacturing. Create, update, or version Product Requirement Specification records to ensure sample data remains consistent and compliant with production standards.
-
Stores the objects used in Industries Einstein Natural Language Processing (NLP) services.
-
IndustriesDigitalLending Namespace
The
industriesDigitalLendingnamespace provides classes used in the Digital Lending OmniScripts and Integration Procedures. -
The
Invocablenamespace provides classes for calling invocable actions from Apex. -
The
InvoiceWriteOffnamespace provides classes to create credit memos with the total charge amount on the invoice as the write-off amount. -
The
IsvPartnersnamespace provides a class associated with Salesforce ISV partner use cases, such as optimizing code, providing great customer trial experiences, and driving feature adoption. -
The
KbManagementnamespace provides a class for managing knowledge articles. -
The
LxSchedulernamespace provides an interface and classes for integrating Salesforce Scheduler with external calendars. -
The
Messagingnamespace provides classes and methods for Salesforce notifications and email functionality. -
The
Metadatanamespace provides classes and methods for working with custom metadata in Salesforce -
The
PlaceQuotenamespace provides classes and methods to create or update quotes with pricing preferences and configuration options. -
The Pref_center namespace provides an interface, classes, and methods to create and retrieve data in forms in Preference Manager. Preference Manager, previously called Preference Center, is a feature within the Privacy Center app.
-
The
Processnamespace provides an interface and classes for passing data between your organization and a flow. -
The
QuickActionnamespace provides classes and methods for quick actions. -
renew_assets_summary Namespace
The renew_assets_summary namespace provides classes that retrieve details about renewable assets to create renewal opportunities.
-
The
Reportsnamespace provides classes for accessing the same data as is available in the Salesforce Reports and Dashboards REST API. -
The
RevSignalingnamespace provides classes to extend the standard procedure plan implementation through custom logic. A procedure plan helps you set up your procedures, configure the procedure execution settings, and relate them to a context definition in one centralized location based on your requirements. -
The
RevSalesTrxnnamespace provides classes and methods to create a sales transaction, such as a quote or an order, with integrated pricing and configuration. -
Provides objects and methods for handling content in enhanced Messaging channels.
-
The RulesAppln namespace contains output classes that store details about a rules-based application of payments and credits.
-
runtime_industries_cpq Namespace
The runtime_industries_cpq namespace provides classes and methods to search products or to manage products, catalogs, and categories.
-
runtime_industries_insurance Namespace
The
runtime_industries_insurancenamespace provides options classes for insurance operations, such as creating and updating insurance quotes, generating insurance clauses, and running insurance rating. -
The
Schemanamespace provides classes and methods for schema metadata information. -
The
Searchnamespace provides classes for getting search results and suggestion results. -
setup_flow_performance Namespace
The class and methods in this namespace are for internal use only.
-
The
SF_Archivenamespace provides classes for testing Apex code that calls Archive Apex. -
The Sfc namespace contains classes used in Salesforce Files.
-
The Sfdc_Checkout namespace provides an interface and classes for B2B Commerce apps in Salesforce.
-
The
sfdc_enablementnamespace provides classes for creating custom learning items to implement custom exercise types in Enablement programs. Lightning web components are used to render the custom exercises on Program Builder. -
The
sfdc_surveysnamespace provides an interface for shortening survey invitations. -
Contains classes that describe Digital Wallet consumption card status and the alerts triggered when consumption crosses a threshold.
-
Contains classes for executing SQL queries against Data 360 data spaces from Apex.
-
The
Sitenamespace provides an interface for rewriting Sites URLs. -
The
SlackNamespace provides tools designed to accelerate and ease the process of developing Slack apps on the Salesforce platform. -
The
Supportnamespace provides an interface used for Case Feed. -
The
Systemnamespace provides classes and methods for core Apex functionality. -
The
TerritoryMgmtnamespace provides an interface used for territory management. -
The
TxnSecuritynamespace provides an interface used for transaction security. -
The
UserProvisioningnamespace provides methods for monitoring outbound user provisioning requests. -
The
VisualEditornamespace provides classes and methods for interacting with the Lightning App Builder. The classes and methods in this namespace operate on Lightning components, which include Lightning web components and Aura components. -
The classes in the
Wavenamespace are part of the CRM Analytics Analytics SDK, designed to facilitate querying CRM Analytics data from Apex code.