What is a formula field?
Data within a formula field is automatically updated by Salesforce based on the formula’s logic.
For instance, the sales team speaks with clients in terms of a monthly and yearly cost. However, the monthly cost is simply the yearly cost divided by 12. Instead of making the reps do the math, we can do it for them. Enter a yearly cost of $120.00, the monthly cost a formula will display $10.00. Change the yearly cost to $240.00, monthly cost is automatically updated to $20.00.
What is a cross-object formula?
A Cross Object Formula is one that references data in a related record. For instance, I could create a formula field on opportunity to display the account’s phone number.
When the account’s phone number gets updated, the field on opportunity automatically reflects the change.
What’s important to know about formulas?
- Formula fields are read-only (the same is true for roll-up summary fields) for all users.
- For this reason, formula fields will not be displayed when editing records. The value of the formula is only calculated after the record is saved. This applies to cross-object formulas as well. For instance, you can easily display the account’s phone number on the opportunity, but you cannot edit the phone number without returning to edit the account record.
Limitations of Formula Fields
There are considerations to be aware of when building formula fields. Notably:
- Formula fields cannot reference several field types, including (but not limited to): Text Area (Long), Text Area (Rich), Picklist (Multi-Select).
- Some formula fields cannot be referenced by roll-up summary fields.
- There are several restrictions on formula size (character, save, compile). You can hit these on long/complex formulas with many arguments.
How do you create a formula field?
Simply create a new field, and select field type “Formula”. Then enter the return type and syntax.
Simple & Advanced Formula Editors
When editing formula syntax, there are two types of editors:
The simple editor does not provide access to cross-object formulas or functions:
I recommend using the Advanced Formula editor, which exposes cross-object variables and functions:
Examples of Advanced Formulas
[Must / Long / Salesforce.com]
100 Sample Formulas to Get you Started
[Should / Long / Salesforce.com]