How to Create Cross-Object Formula Field in Salesforce

I was working as a Salesforce admin on a sales application. Recently, the sales manager asked me to add a field to the contact object so that it would fetch the value of the amount field from the account object and display it on all related contacts of that particular account.

To achieve this requirement, I created a cross-object formula on the contact object that displays the annual revenue amount from the associated account.

Here, I will explain the cross-object formula in Salesforce and how to create a cross-object formula field in Salesforce with an example and step-by-step explanation.

Cross-Object Formula Field in Salesforce

In Salesforce, a cross-object formula field allows you to automatically calculate and display data from multiple related objects within the formula field. It acts as a bridge, pulling information from other objects and presenting it within the current object you’re working with.

Using the cross-object formula field, we can retrieve fields of objects and display them on the related object, known as a cross-object formula.

To create the cross-object formula field, there should be a Master-Detail Relationship or  Lookup Relationship between two objects.

Things to Remember

  • You can create a cross-object formula that references fields from parent objects. That means we can create an object on Chile’s side only. For example, we can fetch from an account to the contacts.
  • We can only follow up to 10 relationships away from fields to fetch the data from the parent object.
  • The cross-object formula is always in the read-only form. We cannot edit them.
  • The cross-object formula follows the field-level security and sharing setting rule. If a user doesn’t have permission to access the field of the parent object, then they won’t be able to access the cross-object formula field either.

Create Cross-Object Formula Field in Salesforce

Here, we will explain how we can display the annual revenue field value from the account object to the related records of the contact object in Salesforce. Using the following steps, we can create a cross-object formula field in Salesforce.

  1. As per our example, we need to display the annual revenue field value from the Account object to the Contact object.
    • For that, go to the Setup. -> Object Manager. -> Click on the Contact Object.
How to Create Cross Object Formula Field in Salesforce
  1. Click on the Field & Relationships. Then, click on the New option.
Cross Object Formula Field in Salesforce
  1. Select the Data Type as the Formula field and click Next.
cross object formula field in Salesforce
  1. Enter the Field Label, as we are displaying the amount field value to the contact, so I have entered ‘Account Amount.’ The Field Name will automatically populate.
    • Then, select the Formula Return Type that matches the desired output if you use the Currency data type field in the parent object. Then, it would be best to select the currency data type in this object.
cross object formula salesforce
  1. Now, click on Advanced Formula. In the Formula Editor, click on the Insert Field option. Then navigate to the Annual Revenue field on Account Object, as displayed in the following Image, and click the Insert button.
Create Cross Object Formula Field in Salesforce
  1. Click Check Syntax to check whether the formula is correct. We cannot proceed to the next step if there is any error.
Create Cross-Object Formula Field in Salesforce
  1. Then, check the Treat Blanks Fields as Zeroes option to handle the null fields, and click the Next button.
Salesforce Cross Object Formula Field
  1. Set up the Field-Level Security so that only selected profile users can access this created field, and the formula field is always read-only. Then click the Next button to proceed and select the Page Layout on which you want to display this cross-object formula field.

After that, click on the Save option.

Salesforce Cross Object Formula
  1. As you click the save button, you will see in the fields and relationships that the cross-object formula field has been created with the label you entered and the data type.
formula field in salesforce
  1. Now, navigate to the Contact Object to check how the formula field works. As you open any contact record with the account name field filled with a value, you will see the formula field displaying the amount, the same as the annual revenue field from the account object.
cross object formula fields in salesforce

This way, we can use the cross-object formula field in Salesforce to fetch the values of the parent fields in the child.

Conclusion

I hope you have an idea about the cross-object formula in Salesforce. I explained what an object formula is and then, using the example, demonstrated how to create a cross-object formula field in Salesforce with a step-by-step explanation.

After creating the cross-object formula, we can fetch the parent data in the child object to provide users with more transparency.

You may also like to read the following Salesforce tutorials.

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.