I am having an issue writing a checkbox formula field on the Opportunity object.
I am trying to use 2 picklist fields – Type
and Stage
. I need the checkbox value to be true if
Type = NULL, New Business, Paywall, or Reactivation AND Stage – Closed Won
Here is my formula:
IF
( ISPICKVAL(Type,"")||
ISPICKVAL(Type,"New Business")||
ISPICKVAL(Type,"Paywall")||
ISPICKVAL(Type,"Reactivation")&&
ISPICKVAL(StageName,"Closed Won"),TRUE, FALSE)
The syntax check is showing no errors. My issue is that the checkbox is being marked TRUE for any StageName value instead of only Closed Won.
Does anyone know what I am doing wrong?
Thank you so much!
Best Answer
I can't find a link to give the order of operations in a formula field, but I think
AND
has precedence overOR
, so your formula is evaluating to:That means it will be TRUE when
Type
= "Reactivation" ANDStage
= "Closed Won"; and it will also be TRUE whenType
= NULL OR "New Business" OR "Paywall" regardless of what theStage
value is.Surround your
Type
selections with parentheses to isolate them and separate them from theStageName
...That should make your formula evaluate to:
Update
To paraphrase what @DerekF said in his comment, the
IF()
is overkill, so you could use this:or, as I prefer to write it: