Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Boolean Operators entry
How-to guide

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.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 19, 2026

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

Gotchas
  • 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.

See the full Boolean Operators entry

Boolean Operators includes the definition, worked example, deep dive, related terms, and a quiz.