Cross Object Formulas in Salesforce

Download Free Salesforce Training Materials with Realtime Scenarios

Cross Object Formulas in Salesforce

Cross Object Formulas in Salesforce refers to fields in records that are related to the current record that the formula is being applied to Example:-. the formula might apply to a Contact record, but in that formula you might want to refer to the related Account record. Salesforce.com has made this very simple and the feature is aptly named Cross Object Formulas.

Note:- To retrieve the data of child records from their parents record the syntax for these references is natural and precise. Consider the situation where you need to create a formula for a Contact record, but you need to refer to the related Account’s parent Account’s name. In this case the syntax would be Account.Parent.name i.e. you access the field value by using the related field names (separated by periods) until you arrive at the object field in question. For custom objects the syntax is slightly different e.g. if the formula applies to a custom object and needs to interrogate the parent object’s name field through the Parent__c relationship field, the syntax would be Parent__r.name.

Where can we use Cross Object Formula in Salesforce?

Cross Object Formulas can be used in a number of areas within the platform as previously mentioned, and depending on their context can be used to achieve different types of results.

What is a Formula Field in Salesforce?

Formula Field in Salesforce are read-only fields with values defined by the underlying formula. Data in these fields are not persisted but is calculated on the fly when the field is accessed. Creating formula fields can be done from the same area as the other field types.

  • Using formula functions you implicitly have access to some “sub” field- types including hyperlinks and images.
  • You are free to use any combination of formula component in formula fields as long as the resultant value is of the pre-determined type.

Never use a formula field as an indexing or filtering value. If you need a field value to be dynamically calculated but know that it will be used to filter data through API calls or in the WHERE clause of any SOQL statement, consider using static fields in combination with workflows instead. The reason here is that the calculation of formulas can be especially taxing “under the hood” to the platform in these conditions and will result in a performance loss.