Notes when referencing a Formula field from another Formula field
|Knowledge Article Number||000230064|
|Description||This article provides some notes and tips for when referencing a formula field from another formula field.|
1. When a formula field references another formula field, it does not simply pull that field's value, but rather it fully executes the formula within the original field.
A formula field called "Pull Forecast Value" on object "Test" which is related to "Opportunity", has this simple formula:
The field "Forecast Value" on the Opportunity object is a formula field. In this case, it is important to note that the "Pull Forecast Value" formula field does not simply extract the current value of the "Opportunity__r.Forecast_Value__c", but actually executes the formula within the "Forecast Value" formula field, to derive the value
2. If the formula field "Forecast Value" on the Opportunity object contains a formula similar to the below, then running that formula through another formula field as exampled in note 1 from another object, will likely fail due to the use of the dynamic Global Variable of $RecordType.Name:
IF(CONTAINS($RecordType.Name, 'OppName 1'), Estimated_Revenue__c * Gross_Margin_Percent__c ,
IF(CONTAINS($RecordType.Name, 'OppName 2'), Gross_Margin_Percent__c * Amount ,
IF(CONTAINS($RecordType.Name, 'OppName 3'), Gross_Margin_Percent__c * Amount ,
The above would fail to execute as expected from the "Test" object, because the Global Variable for $RecordType.Name will evaluate against the RecordType Names from the current "Test" object which will not match the Opportunity Record Type names. In this case one could simply reference the RecordTypeId values instead of the Name values, which will still evaluate correctly, even if ran from the "Test" object formula field's execution point.
*See these related Articles and Documentation:
Understanding Global Variables
Formula Field exceeds maximum number of characters