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
Yaswanth KothapalliYaswanth Kothapalli 

Validation Rule on 2 Lookup Fields

Hi All,

I have an object with 2 lookup fields in it. My scenario goes in this way-
1. If User selects both the lookup fields in detail page and Click on Save, it should throw the Validation Error to select any one of lookup instead of both

Thanks
Best Answer chosen by Yaswanth Kothapalli
Sanpreet SainiSanpreet Saini
Below Validation rule is working fine. 


if(And(AccountNumber!=null , Description!= null),true,false)

Regards, 
Sanpreet

All Answers

Abhishek BansalAbhishek Bansal
Hi,

You can use below formula in your validation rule :

AND(NOT(ISNULL(First_Lookup_Field__c)), NOT(ISNULL(Second_Lookup_Field__c)))

Please let me know if you need any other help.

Thanks,
Abhishek Bansal.
 
Sanpreet SainiSanpreet Saini
Below Validation rule is working fine. 


if(And(AccountNumber!=null , Description!= null),true,false)

Regards, 
Sanpreet
This was selected as the best answer
Yaswanth KothapalliYaswanth Kothapalli
Thanks Abhishek and Sanpreet !! 

Sanpreet logic worked !!
Pranav ChitransPranav Chitrans
And(Not(Isblank(Lookup1__c)) , NOT(Isblank(Lookup2__c)))

Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.

Text fields are never null, so using ISNULL() with a text field always returns false. For example, the formula field IF(ISNULL(new__c) 1, 0) is always zero regardless of the value in the New field. For text fields, use the ISBLANK function instead.

Hope this will help :)
Regards Pranav