Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Formula Evaluation in Apex
Formulas in Apex support these features.
- Reference Apex types in formula fields. The values contained in individual components of such Apex types are accessed and evaluated by the formula. Address, Location, URL, and UUID System types are supported.
- Reference standard lookups and custom lookups in formula fields.
- Access polymorphic relationship fields.
- Access the return value from the toString() method in formula fields.
Formula evaluation in Apex is bound by the formula field character limit, but not the compile size limit. A formula can contain up to 3,900 characters including spaces, return characters, and comments.
Formula functions that are available to use in Apex are ones that can be used in validation rules. For details, see Formula Operators and Functions by Context.