function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael M 

Formula to 2 lookup fields

Conditional Formula
My Lead object has 2 lookups fields: one to a custom object, and one to Opportunity. In some scenarios, only one of those lookup fields will be populated. The custom object and Opportunity object both contain fields that record the same information relevant to the Lead. I need to create a formula field on Lead, that looks to BOTH objects to display its formula, so that if one of the lookup fields is not populated, the relevant information will display on the Lead record from the other lookup record. How would I write that formula? Here is a template which of course doesn't work, but is the point where I'm stuck. 

1. This one would be for a checkbox formula field

IF(CustomRehosp__r.Concerns__c =true, IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30),"")

ELSE 
IF(Opportunity.Concerns__c =true, IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30),"")

2. This one would be for a text formula field
CustomRehosp__r.Concern_Notes__c
ELSE
Opportunitiy.Concern_Notes__c 
Best Answer chosen by Michael M
Maharajan CMaharajan C
Hi Michael,

Try the below ways:

1. IF(  CustomRehosp__r.Concerns__c =true , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30), IF( Opportunity.Concerns__c =true , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30),"" ) )

2. IF(  NOT(ISBLANK(CustomRehosp__r.Concern_Notes__c)) , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30), IF( NOT(ISBLANK(Opportunitiy.Concern_Notes__c)) , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30),"" ) 
)

Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Hi Michael,

Try the below ways:

1. IF(  CustomRehosp__r.Concerns__c =true , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30), IF( Opportunity.Concerns__c =true , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30),"" ) )

2. IF(  NOT(ISBLANK(CustomRehosp__r.Concern_Notes__c)) , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30), IF( NOT(ISBLANK(Opportunitiy.Concern_Notes__c)) , IMAGE('/servlet/servlet.FileDownload?file=0152g0000009NGo',"",30,30),"" ) 
)

Thanks,
Maharajan.C
This was selected as the best answer
Michael MMichael M
Thank you! 1 seems to work. 

For 2, I don't want to display the image, I simply want to display the text of "Concern Notes" field. 
So if CustomRehosp__r.Concern_Notes__c is filled in, I want that text to display on the lead, and if not, then if Opportunity.Concern_notes__c is filled in then I want to display that. Can that be done? 
Maharajan CMaharajan C
2.  IF(  NOT(ISBLANK(CustomRehosp__r.Concern_Notes__c)) , CustomRehosp__r.Concern_Notes__c , IF( NOT(ISBLANK(Opportunitiy.Concern_Notes__c)) , Opportunitiy.Concern_Notes__c ,"" ) 
)


Thanks,
Maharajan.C
Michael MMichael M
You're the man!