How to Use Formula Fields to Display Related Data on a Record
What is a formula field?
Formula fields are a custom field type unique to custom objects. Formula fields use data in other fields in a formula and display the result as the field value.
For example, if your custom object represented a school and you had a field for each classroom counting the number of students, a formula field could be used to display the total number of students by adding all of the field values together.
You cannot directly enter or edit the data displayed by a formula field. The formula field will appear “greyed-out” or not editable on your custom object records.
Using Formula Fields to Display Related Data on a Record
Custom objects can be related to other objects through lookup fields. In your day-to-day use of the system, you might find it convenient to display fields from the related records directly on your custom object.
For example, most custom objects are related to an account. If your custom object represented adopted animals, you might want to have the owner's phone number displayed directly on the custom object record, so you don’t need to navigate to the owner's account to find it when you’re checking up on your rescued critters.
-
To create a formula field, navigate to Global Settings > Custom Objects > Click into your object > Add Field (make sure the custom object is set to inactive to allow adding a new field).
-
Select Formula as the field type and click Next.
-
Add a field label
-
Select the return type, which should match the type of data you wish to display. For example, if you are displaying a text field, select Text as your return type.
-
Click into the white box to the right of Formula
-
Click Insert Field
-
In the Select Field menu, click on the related record you want to display a value from.
-
Select the field you want to display from the sub-menu on the right and click Insert Token. Here is a screenshot using our animal owner phone number example:
9. Click Save in the top-right corner