This article explains why a cross-object formula field returns a partial value instead of null when the lookup relationship field connecting the two objects is blank in Salesforce.
A cross-object formula on one object that references a formula field on a related object may still return a non-null value even when the relationship (lookup) field connecting the two objects is empty.
Consider two objects — Object A and Object B:
text_field__c & "@test.com"Object_A__r.formula_field__cResult: On an Object B record where the lookup to Object A is blank, the formula on Object B displays "@test.com" instead of null.
Salesforce-specific example: On an Opportunity record with a lookup to Account, if a formula on the Opportunity references Account.Email_Domain__c (a formula field on Account that appends "@company.com" to a domain text field), the Opportunity formula returns "@company.com" even when the Account lookup field is empty.
This is expected behavior in Salesforce. When a formula field references another formula field, Salesforce pulls in the underlying syntax of the referenced formula — not just its current value. This means the formula on Object B effectively evaluates the full expression Object_A__r.text_field__c & "@test.com" directly.
When the lookup to Object A is blank, Salesforce cannot retrieve Object_A__r.text_field__c, so that portion of the formula evaluates to null. The remaining formula logic evaluates as null & "@test.com", which outputs "@test.com".
To prevent a cross-object formula from returning partial values when the lookup field is blank, wrap the formula with an IF function that checks whether the lookup relationship is null before evaluating the formula expression.
Updated formula example for Object B:
Use an IF statement to first check if the Object A lookup is populated. If the lookup is blank (null), return null. If the lookup is populated, evaluate the cross-object formula as intended. For example: IF(ISNULL(Object_A__r.Id), NULL, Object_A__r.formula_field__c).
This prevents the formula from returning partial text values (such as "@test.com") when the lookup relationship field is empty.
000381947

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.