What are best practices for formula fields, including cross-object formulas and recursive formula dangers?
Suggested answer
Formula fields are calculated at query time. Key best practices:
Cross-object formulas: Can traverse up to 5 levels of relationships (e.g., Account.Owner.Manager.Name). Limit: 10 unique relationships per formula field, 5 across all formula fields per object for certain traversals. Avoid on high-volume objects where the traversal causes performance overhead.
Null handling: Use BLANKVALUE() instead of ISNULL() for text fields (ISNULL treats empty string as non-null). Use NULLVALUE() for numbers. Always account for null parent records in cross-object formulas to prevent formula returning null.
Recursive formula danger: Formula fields cannot directly reference themselves, but complex circular references between related objects can occur with workflow/trigger loops. For example, Object A's formula depends on Object B's formula, which triggers a workflow on A. Always map dependencies before adding cross-object references.
Performance: Formula fields are not stored on the record — recalculated on every read. For very large datasets, replace complex formulas with stored fields updated by triggers or flows to improve query performance.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.