+ Start a Discussion
DaveGCDaveGC 

Workflow formula check Stage change

Hello, I need to create a workflow rule that triggers when the opportunity stage changes and sends an email, as long as it doesn't change to some values, this is what I got that isn't working:
 
IF(
ISCHANGED(StageName) 
AND (
 NOT(ISPICKVAL(StageName, "Value 1")), 
 NOT(ISPICKVAL(StageName, "Value 2")),
 NOT(ISPICKVAL(StageName, "Value 3")),
 NOT(ISPICKVAL(StageName, "Value 4"))
))

 
Best Answer chosen by DaveGC
Akhil AnilAkhil Anil
Hi Dave,

You don't need an IF condition there. You just have to wrap them all inside an AND statement. I would highly recommend to use a CASE function here because you have multiple values to be compared and a CASE function is the way to go for such scenarios. Your formula should be as simply as this
 
AND(
ISCHANGED(StageName),
CASE(StageName,
"Value 1",1,
"Value 2",1,
"Value 3",1,
"Value 4",1,
0) = 0
)

That will work !

@Lee - The formula you have posted wraps all the negative conditions within an OR statement which is logically incorrect and will yield the wrong results.

 

All Answers

Christopher TaylorChristopher Taylor
Remove if from your formula.  The system will see it as checking that the condition is true.  If the condition is not true the workflow will not trigger.  The "if" is implicit in the application. so it should read

AND(ISCHANGED(StageName),
       OR(NOT(ISPICKVAL(StageName, "Value 1")),
            NOT(ISPICKVAL(SageName, "Value 2")),
            NOT(ISPICKVAL(StageName, "Value 3")),
            NOT(ISPICKVAL(StageName, "Value 4")),
       )
)
Akhil AnilAkhil Anil
Hi Dave,

You don't need an IF condition there. You just have to wrap them all inside an AND statement. I would highly recommend to use a CASE function here because you have multiple values to be compared and a CASE function is the way to go for such scenarios. Your formula should be as simply as this
 
AND(
ISCHANGED(StageName),
CASE(StageName,
"Value 1",1,
"Value 2",1,
"Value 3",1,
"Value 4",1,
0) = 0
)

That will work !

@Lee - The formula you have posted wraps all the negative conditions within an OR statement which is logically incorrect and will yield the wrong results.

 
This was selected as the best answer
DaveGCDaveGC
@akhil are you adding the "=0" so that if one of the case conditions is true, it will negate the formula?
Akhil AnilAkhil Anil
You got it right David !
DaveGCDaveGC
Thank you!