What I am trying to do is have the Checkbox value be marked True if 'Email' is blank OR if 'HasOptedOutofEmail' (A Checkbox Field) is marked True (Checked). If Email is populated or Opted Out is not true, I want the Checkbox field to remain unchecked. Does this formula fit this criteria?

OR (
    NOT (
        HasOptedOutOfEmail =True'

1 Answer 1


No, I don't think it does. I think the formula you've worked out so far is somewhat close (albeit with some syntax and semantic errors).

Your description seems to be incomplete. You've described what you want to happen when Email is populated/not blank (those two are the same thing, in my mind) when HasOptedOutOfEmail is both true and false, but you haven't specified what should happen if Email is blank.

Based on your description, I infer that this is a "can we email this person?" checkbox. In that case, having no email should lead to this field being set to false (unchekced).

So, the complete description of what you're trying to do would look like:

  • return false if email is blank
  • return false if email is populated and HasOptedOutOfEmail is true
  • return true otherwise

I think the following is what you're looking for

IF( /* IF function takes 3 arguments: the condition, the value if true, the value if false*/
    false, /* When email is blank, preventEmail = false */
    NOT(HasOptedOutOfEmail) /* When email is populated, preventEmail depends solely on HasOptedOutOfEmail */


Now that the question has been clarified, the equivalent expression is
isEmailBlank || !isEmailBlank && hasOptedOut

distributing the OR over AND
(isEmailBlank || !isEmailBlank) && (isEmailBlank || hasOptedOut)

x || !x is always true
true && y reduces to y

You don't need to compare a boolean value like HasOptedOutOfEmail to true or false, you can just use it directly in the (boolean) formula

So the formula you're looking for is

  • My mistake. I want the formula to return true if Email is blank or if the "Can we email this person" checkbox is true. If there is an email value or if the "Can we email this person" is not checked, I want to return a value of false. Mostly, I'm trying to determine if 1) The Record has an email and 2) If the Record has opted out.
    – user97276
    Jul 16, 2021 at 18:02
  • @JD15 answer updated
    – Derek F
    Jul 16, 2021 at 18:20
  • Don't you need to compare the boolean value to ensure the formula field is continuously updated? Such as if Email is no longer blank or opt out becomes false?
    – user97276
    Jul 16, 2021 at 18:36
  • @JD15 Nope. Formulas are recalculated every time a record is read from the database (viewed in the UI, queried, or involved in a trigger). They're literally stored as the formula (and whatever database(s) Salesforce uses computes the value on each read). Formulas aren't recalculated if you modify an in-memory instance of the SObject (i.e. modify a variable in Apex or modify a record in a Trigger context variable, unless you then pass the records into Formula.recalculateFormulas()), and including things like HasOptedOutOfEmail = true does not change that.
    – Derek F
    Jul 16, 2021 at 18:46

You must log in to answer this question.