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
Sanchi9Sanchi9 

Validation rule if one field is empty

Hi,

Given there are two fields A and B.
We can only enter values in field A only if field B is empty. 
What validation rule should I write for this?  
Best Answer chosen by Sanchi9
Sanchi9Sanchi9
Hi ANUTEJ,

Thank you for answering my question, but somehow that validation rule didn't work. Although I tried another one and it worked for me. 

( IF(ISBLANK(Field_A__c),0,1) + IF(ISBLANK(Field_B__c),0,1) ) > 1

Thanks!

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Priya,

I think you can try the below one:
AND(ISBLANK(Field_A__c),Not(ISBLANK(Field_B__c)))
This works when field a is empty and field b is not and this wouldn't show any error when we enter values in field A only if field B is empty.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Sanchi9Sanchi9
Hi ANUTEJ,

Thank you for answering my question, but somehow that validation rule didn't work. Although I tried another one and it worked for me. 

( IF(ISBLANK(Field_A__c),0,1) + IF(ISBLANK(Field_B__c),0,1) ) > 1

Thanks!
This was selected as the best answer