Difference between && II and AND OR - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Carlos SiqueiraCarlos Siqueira 

Difference between && II and AND OR

I read somewhere that there is a difference between "&& II" and "AND OR", but would like a bit more of clarification, since it doesn't seem to be just preference as they are not equally equivalent.

This formula on my Process Builder saves/works fine:

NOT (ISBLANK( [Opportunity].MainCompetitors__c  ))
&&
([Opportunity].MainCompetitors__c = "IBM" ||
[Opportunity].MainCompetitors__c = "Oracle" )

If I change the "&&" for "AND" and "II" for "OR", it doesn't save and tells me that I have an extra "AND"

NOT (ISBLANK( [Opportunity].MainCompetitors__c  ))
AND
([Opportunity].MainCompetitors__c = "IBM" OR
[Opportunity].MainCompetitors__c = "Oracle" ) 

A friend mentioned: `&&` and `||` are operators. `AND()` and `OR()` are more like functions/methods.
While I have a background in programming, it was on mainframes, not the more modern languages today.
If somebody can show me how to have the working 1st example above changed to && II, I would appreciate.

Thanks
Best Answer chosen by Carlos Siqueira
Ritika BhargavaRitika Bhargava
Hi Carlos,

Agree with your friend! These are termed differently, but internally and specifically in Salesforce formulas, these are one and the same thing. 

The usage for these two are entirely different. For example, && can be used to check expression as - Carlos && Carla
AND function usage will be: AND ( Carlos, Carla)

Using this logic the formula can be updated as:
 
NOT ( 
     AND ( ISBLANK( [Opportunity].MainCompetitors__c  ),
               OR([Opportunity].MainCompetitors__c = "IBM",
                      [Opportunity].MainCompetitors__c = "Oracle" ) ))



For further reference: https://trailhead.salesforce.com/modules/advanced_formulas/units/implementing_advanced_formulas

All Answers

Steve MolisSteve Molis
The syntax with AND OR is a little different than && || but they function in much the same way.  I would just use whichever one you are comfortable writing with
Ritika BhargavaRitika Bhargava
Hi Carlos,

Agree with your friend! These are termed differently, but internally and specifically in Salesforce formulas, these are one and the same thing. 

The usage for these two are entirely different. For example, && can be used to check expression as - Carlos && Carla
AND function usage will be: AND ( Carlos, Carla)

Using this logic the formula can be updated as:
 
NOT ( 
     AND ( ISBLANK( [Opportunity].MainCompetitors__c  ),
               OR([Opportunity].MainCompetitors__c = "IBM",
                      [Opportunity].MainCompetitors__c = "Oracle" ) ))



For further reference: https://trailhead.salesforce.com/modules/advanced_formulas/units/implementing_advanced_formulas
This was selected as the best answer
Ankush DurejaAnkush Dureja
In salesforce formulas, process builder, validation rules
AND(), OR() are functions, For example
AND (true,true)
will return true. Chek this link 
https://help.salesforce.com/articleView?err=1&id=customize_functions_a_h.htm&type=0

&&, || are operators. for example
true && true
will return true. Check this link
https://help.salesforce.com/articleView?id=customize_functions.htm&type=0

Taking your example. This code will not compile:

NOT (ISBLANK( [Opportunity].MainCompetitors__c  ))
AND
([Opportunity].MainCompetitors__c = "IBM" OR
[Opportunity].MainCompetitors__c = "Oracle" ) 

You need to use

NOT (ISBLANK( [Opportunity].MainCompetitors__c  ))
&&
([Opportunity].MainCompetitors__c = "IBM" ||
[Opportunity].MainCompetitors__c = "Oracle" )
Carlos SiqueiraCarlos Siqueira
Thank you all.
This is what I understood:
AND(xxxxxx)  and OR(yyyyyyy) would imply that xxxxxx and yyyyy are more complex structures wrapped under the functions AND/OR, like every expression on xxxxx must be met and any expression on yyyy can be met.
&& and II would be more like a connector between simpler expressions?
Ritika BhargavaRitika Bhargava
Yes, agreed Carlos :)
SANDEEP Thouti ReddySANDEEP Thouti Reddy
Hi,

The below validation rule doesn't work..

IF((Salary__c > 10000 && Bonus__c > 10), TRUE, FALSE)

But this works..

AND (Salary__c > 10000, Bonus__c > 10)

Can you please explain why?
Steve MolisSteve Molis
SANDEEP Thouti Reddy 

Validation Rules are boolean, so there is no need to use IF( TRUE , FALSE )