[SalesForce] Multiple OR statements in Validation Rule

Im trying to figure out a Validation Rule
IF Picklist Value is "Yes", then 4 fields must be filled out AND at least 1 of 2 Solution Partner fields must be Filled out.
I can figure out how to require all fields, but Im getting stuck on how to add additionally at least 1 of 2 Solution Partner fields have to have values.

AND(
$RecordType.Id = "0125p000000eVI2",
ISPICKVAL( Picklist_Field,"Yes")

&&
OR(
ISBLANK(Main_Contact__c),
ISBLANK(Services__c),
ISBLANK (Contact_1__c),
ISBLANK(Decision_Maker__c)
)

&&

OR(
ISBLANK(Solutions_Partner1__c )
||
ISBLANK(Solutions_Partner2__c))

(this last Part is where I get an issue) if set up like this, Im able to save without either of the Solutions Partners

Best Answer

Either use an OR function or || operator, correct syntax for both would be:

  1. OR(Condition1, Condition2)
  2. Condition1 || Condition2

Whereas you have written it as OR(Condition1 || Condition2), that is not valid.

Indenting formulas can be extremely helpful in finding some trivial issues with syntax. This is an example of formula with AND/OR functions to improve readability-

AND(
    $RecordType.Id = "0125p000000eVI2", 
    ISPICKVAL( Picklist_Field,"Yes"),
    OR( 
        ISBLANK(Main_Contact__c), 
        ISBLANK(Services__c), 
        ISBLANK (Contact_1__c), 
        ISBLANK(Decision_Maker__c) 
    ),
    OR( 
        ISBLANK(Solutions_Partner1__c),
        ISBLANK(Solutions_Partner2__c)
    )
)

Note: I may have made a mistake in converting operator or in conditions, please check.


Edit: Seems you need a XOR condition, replace the OR condition with below:

(ISBLANK(Solutions_Partner1__c) != ISBLANK(Solutions_Partner2__c))
Related Topic