Boolean Operators
Boolean Operators in Salesforce are the logical connectives (AND, OR, NOT) that combine multiple conditions into one composite expression.
Definition
Boolean Operators in Salesforce are the logical connectives (AND, OR, NOT) that combine multiple conditions into one composite expression. They appear in nearly every place Salesforce evaluates a condition: validation rule formulas, Flow decision elements, report filters, list view filters, SOQL WHERE clauses, search expressions, sharing rule criteria, and approval-process entry criteria. The semantics are the same as Boolean algebra anywhere else: AND is true only when both sides are true; OR is true when at least one side is true; NOT inverts the value. The platform-specific detail is that different surfaces use slightly different syntax (text in some, symbols in others, parentheses in all).
Boolean Operators are the difference between a simple match and a real business rule. Closed Won and Amount > 100k is two conditions joined by AND. Industry equals Healthcare or Industry equals Life Sciences is two conditions joined by OR. NOT(IsClosed) is the negation pattern that catches everything except closed records. Mastering Boolean Operators is a foundational Salesforce skill because the same logic shows up in every automation tool, every report builder, every formula field. The mistakes are universal too: missing parentheses change the meaning, mixing AND and OR without grouping produces unexpected results, and treating NULL like false produces wrong answers in places like Flow conditions where it should be ISBLANK or null checks.
Boolean Operators across Salesforce surfaces
Validation rules and formula syntax
Validation rules and formula fields use AND(condition1, condition2, ...), OR(condition1, condition2, ...), NOT(condition). The function syntax is unusual; Salesforce's formula language wraps Boolean Operators as functions rather than using infix notation. Combining them looks like AND(OR(A, B), NOT(C)). Parentheses always disambiguate.
SOQL and Apex syntax
SOQL uses infix AND, OR, NOT inside WHERE clauses: SELECT Id FROM Account WHERE Industry = 'Technology' AND AnnualRevenue > 1000000. Apex code uses standard programming syntax: && for AND, || for OR, ! for NOT. The two surfaces differ but behave the same way semantically.
Flow Decision elements
Flow decision elements let admins combine multiple conditions with All Conditions Are Met (AND), Any Condition Is Met (OR), or Custom Condition Logic (free-form 1 AND (2 OR 3) using condition row numbers). Custom Condition Logic is what handles non-trivial Boolean expressions in declarative tools without writing formulas.
Report and list view filters
Reports and list views default to combining filter rows with AND. The Filter Logic field on each report lets admins override with Custom Filter Logic (1 AND (2 OR 3)). Without the override, three filter rows mean all three must be true; with custom logic, OR or NOT can be mixed in.
Search and SOSL
SOSL FIND expressions support AND, OR, and operators for word combinations: FIND {Acme AND Corp} returns matches with both words. Quoted phrases bind tighter than Boolean Operators; parentheses disambiguate complex queries.
Approval process entry criteria
Approval Process entry criteria support filter logic and formula expressions. The same AND/OR/NOT rules apply. Multi-clause criteria (Stage = Negotiation AND Amount > 100k OR Type = Enterprise) need parentheses to express the intended grouping; the default AND join across filter rows is rarely what you want for complex rules.
NULL handling and three-valued logic
Salesforce evaluates NULL as neither true nor false in many surfaces. AND(true, null) is null, not true. OR(true, null) is true. NOT(null) is null. The behaviour mirrors SQL three-valued logic and is the source of many surprising formula results. Always combine Boolean Operators with ISBLANK or null checks when fields can be empty.
Common pitfalls and best practices
Three patterns recur. Missing parentheses change meaning silently: AND(A, OR(B, C)) is different from OR(AND(A, B), C). Mixing AND and OR without grouping produces wrong results. And reliance on default filter-row AND in reports when the rule actually needs OR is the most common report-builder mistake. Always write the rule with explicit grouping for non-trivial logic.
How to use Boolean Operators correctly
Boolean Operators are simple in concept and easy to get wrong in practice. The patterns below cover the surfaces where Salesforce admins and developers spend most of their time.
- Write down the business rule in plain English
Before opening the formula editor, write the rule out: Only when X and either Y or Z but not W. The plain English version is the contract; the formula is the translation.
- Translate to the right surface syntax
Validation rule formulas use AND(), OR(), NOT(). Flow decisions use All/Any/Custom Logic. SOQL uses infix AND/OR/NOT. Apex uses &&/||/!. The semantic rule is the same; the syntax varies.
- Add parentheses for any non-trivial expression
Whenever AND and OR mix in the same expression, group with parentheses. Operator precedence works but is the source of most reading-bugs.
- Handle NULL explicitly
When a referenced field can be blank, combine ISBLANK or null checks with the Boolean Operators. Three-valued logic silently breaks formulas that assume NULL is false.
- Test against representative records
Boolean Operators are easy to get logically wrong. Test the rule against records that should match and records that should not. The test plan catches the parentheses bug that pure inspection misses.
- Missing parentheses change meaning silently. AND(A, OR(B, C)) differs from OR(AND(A, B), C); always group complex logic.
- Default filter-row AND in reports is the most common report-builder mistake. Set Custom Filter Logic when the rule actually requires OR.
- NULL behaves as three-valued logic. AND(true, null) is null, not true; reliance on Boolean-only thinking produces wrong answers.
- Apex && short-circuits, but formula AND() evaluates both arguments. Performance differences matter on heavy formulas with side effects.
Trust & references
Cross-checked against the following references.
- Formula Operators and FunctionsSalesforce Help
- Filter Logic in ReportsSalesforce Help
Straight from the source - Salesforce's reference material on Boolean Operators.
- SOQL Conditional ExpressionsSalesforce Developer Docs
Hands-on resources to go deeper on Boolean Operators.
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What are the three main boolean operators?
Q2. Which of these uses boolean operators in Salesforce?
Q3. What does a NOT operator do?
Discussion
Loading discussion…