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
sfdc-admin-smsfdc-admin-sm 

Need help with a nested If formula for Validation rule pls!

Hello all,

 

I have a Lead validation rule using an IF statement that works as follows:

 

IF(AND(ISPICKVAL(Status, "Junk") , ISPICKVAL(junk_reason__c , "") ),TRUE, FALSE)

 

This IF statement works fine for checking 2 picklist values of 2 different lead picklist fields. However, I want to add another IF condition such as:

 

IF(AND(ISPICKVAL(Status, "Junk") , ISPICKVAL(junk_reason__c , "Bad Email") ),TRUE, FALSE)

 

How would I combine these 2 IF statements or merge into a Case function? The idea is if either of these 2 IF statements evaluate to True then the Lead Validation rule error message will display.

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
amritamrit

Hi,

 

You can use AND(ISPICKVAL(Status, "Junk") , ISPICKVAL(junk_reason__c , ""))|| AND(ISPICKVAL(Status, "Junk") , ISPICKVAL(junk_reason__c , "Bad Email")) like this.

 

Please accept as solution if it works .

All Answers

amritamrit

Hi,

 

You can use AND(ISPICKVAL(Status, "Junk") , ISPICKVAL(junk_reason__c , ""))|| AND(ISPICKVAL(Status, "Junk") , ISPICKVAL(junk_reason__c , "Bad Email")) like this.

 

Please accept as solution if it works .

This was selected as the best answer
sfdc-admin-smsfdc-admin-sm
Thanks amrit. This worked.
Veena GopalVeena Gopal
this is not a doubt or example for nested if.

Nested ifs example would be IF(logical_test, value_if_true, value_if_false). there should be a criteria in the logical_test and in the value_if_true another IF should be inserted.