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
SFDCneophyteSFDCneophyte 

Cross object formulas... Again

Hello All,

 

I'm trying to populate a TEXT field on a custom object. The goal is to check for an Account Name on the Lead Object or on the  Contact Object.  Based on my formula below I'm getting a eror. Any help would be greatly appreciated.

 

Thanks,

 

 

IF
(OR(Lead__r.Account__r.Name),
(OR(Contact__r.Account.Name)),
null)

 

Error: Incorrect parameter for function 'OR()'. Expected Boolean, received Text

Best Answer chosen by Admin (Salesforce Developers) 
phiberoptikphiberoptik

So you created a custom object called Account? Leads are not related to Accounts natively.

 

The key question is can a Lead AND a Contact be related to the custom object at the same time? If so, then which one wins if they are both are populated, since your field can only accept one or the other.

 

For example, this will populate the Contact Account Name if they are both populated.

 

IF(NOT(ISBLANK(Lead__r.Account__r.Name))&& ISBLANK(Contact__r.Account.Name), Lead__r.Account__r.Name,
   IF(NOT(ISBLANK(Contact__r.Account.Name))&& ISBLANK(Lead__r.Account__r.Name), Contact__r.Account.Name,
        IF(NOT(ISBLANK(Lead__r.Account__r.Name))&& NOT(ISBLANK(Contact__r.Account.Name)), Contact__r.Account.Name,
null)))

 

All Answers

phiberoptikphiberoptik

Leads do not have Account Names, is your custom object related to both Leads and Contacts? And only one or the other can be related to the object at the same time?

 

 

SFDCneophyteSFDCneophyte

My custom object is related to both the lead object as well as the contact object. Essentially an Account Record can have both leads and contacts.  So our leads and contacts can be linked to an account.  

phiberoptikphiberoptik

So you created a custom object called Account? Leads are not related to Accounts natively.

 

The key question is can a Lead AND a Contact be related to the custom object at the same time? If so, then which one wins if they are both are populated, since your field can only accept one or the other.

 

For example, this will populate the Contact Account Name if they are both populated.

 

IF(NOT(ISBLANK(Lead__r.Account__r.Name))&& ISBLANK(Contact__r.Account.Name), Lead__r.Account__r.Name,
   IF(NOT(ISBLANK(Contact__r.Account.Name))&& ISBLANK(Lead__r.Account__r.Name), Contact__r.Account.Name,
        IF(NOT(ISBLANK(Lead__r.Account__r.Name))&& NOT(ISBLANK(Contact__r.Account.Name)), Contact__r.Account.Name,
null)))

 

This was selected as the best answer
SFDCneophyteSFDCneophyte

OK,  I created a custom object called "Prospects"  this custom object was created to specifically track the progess of leads as they move through our system .So a prospect can be a "Lead" or a "Contact" So if I create a new prospect record and that person is a lead  or a contact I would want the system to identify the name entered and then return the Account associated with this individual, be it Lead or Contact.... Possible?

 :) 

phiberoptikphiberoptik

Sorry I edited my last reply while you were replying. See the formula above.

SFDCneophyteSFDCneophyte

Thank you once again! I hope you don't mind if I add you as a friend... Thanks,  - Keith

phiberoptikphiberoptik

Glad to help. Happy to be a friend... unless youre a psycopath lol