Validation rule help!

Okay so, I've been noodling on this for hours and I'm at a point where I need help.

Scenario:

FOR ALL USERS (except 3 specific profiles), they cannot change the value of the Status field from "Complete" to anything else.

BUT for those 3 specific profiles, they can change it to "Hold". Otherwise, they ALSO cannot change it to anything other value. This is what I've written, no syntax errors right now, but it's not working - as a sys admin, I cannot change it from "Complete" to anything else, not even "Hold".

I thought by ORing the entire statement, it would look at BOTH scenarios and only trigger the error if one of them was true. But it seems to be disregarding the first half of the statement/always triggering the error no matter what status I change it to as an Admin.

OR

(

AND(

ISPICKVAL(PRIORVALUE( Status__c ), “Complete”),

NOT(ISPICKVAL(Status__c, “Complete”)),

NOT(ISPICKVAL(Status__c, “Hold”)),

OR(

$Profile.Name = ‘System Administrator’,

$Profile.Name = ‘X’,

$Profile.Name = ‘Y’)

),

AND(

ISPICKVAL(PRIORVALUE (Status__c) , “Complete”),

NOT(ISPICKVAL(Status__c, “Complete”))

)

)

Any help/suggestions would be greatly appreciated!

Posted Sep 16, 2019, 6:49 PM UTC

210
exus_dominus•

Your 1st condition seem to be firing in the opposite of when you want them. Try wrapping a NOT() around the profile checks.

-Edit to specify first condition.

E.g NOT(OR( Profile = X, profile = y))

2
danimarooOP•

Thanks! This is what I've updated it to based on your feedback and unfortunately it doesn't work.

Not sure if I want that though because what I'm saying is, if any of those profiles are used and they change the status from Complete to anything except Hold, fire off the validation rule. So wouldn't I not want the NOT in front of the profiles so it looks at applying this specific criteria when those profiles are used ?

OR(

AND
(
ISPICKVAL(PRIORVALUE( Status__c ), "Complete"),
NOT(ISPICKVAL(Status__c, "Complete")),
NOT(ISPICKVAL(Status__c, "Hold ")),
NOT(OR($Profile.Name = 'System Administrator',
$Profile.Name = 'X',
$Profile.Name = 'Y'))
),

AND(
ISPICKVAL(PRIORVALUE (Status__c) , "Complete"),
NOT(ISPICKVAL(Status__c, "Complete"))
)
)

1
exus_dominus•

Keep the NOT around the profiles but change the OR to AND. The logic is currently if it's not admin then block profile x, if it's not profile x then block admin.

So you want NOT(AND (PROFILE = ADMIN, PROFILE = X, PROFILE = Y))

2
danimarooOP•

Unfortunately that didn't work BUT I did get myself to this point and I have this part working (I went the IF route instead to see where it'd take me, and there is progress):

IF(
(ISPICKVAL(PRIORVALUE( Status__c), "Complete") &&
NOT(
OR(
ISPICKVAL(Status__c, "Hold"),
ISPICKVAL(Status__c, "Complete")))

&&

OR($Profile.Name = 'System Administrator',
$Profile.Name = 'X',
$Profile.Name = 'Y')),

TRUE, FALSE)

So now anyone under those 3 profiles will hit the validation rule unless they change from Complete -> Hold, then it saves no problem.

Now I just need to figure out how to implement this part for all other users, and not have crap out on me/not work, haha:

AND(
ISPICKVAL(PRIORVALUE (Status__c) , "Complete"),
NOT(ISPICKVAL(Status__c, "Complete"))
1
exus_dominus•

Try this:

​

AND(

ISPICKVAL(PRIORVALUE( Status__c ), 'Complete'),

NOT(ISPICKVAL(Status__c, 'Complete')),

​

(

AND(

OR($Profile.Name = 'System Administrator',

$Profile.Name = 'X',

$Profile.Name = 'Y'

),

NOT(

OR(

ISPICKVAL(Status__c, 'Hold'),

ISPICKVAL(Status__c, 'Complete')

)

)

)

)

)

1
danimarooOP•

No go. Worked for me as an Admin in preventing me from doing anything but moving Complete -> Hold. But when logged in as a user that is NOT one of those profiles, I am able to update the status to anything I want when it's marked as Complete.

I ran into this same issue with my IF statement when I added in the extra logic. :( I really appreciate the help though.

1
recesshustlerkid•

What about this?

IF (

NOT ( OR ($Profile.Name = 'System Administrator',

$Profile.Name = 'X',

$Profile.Name = 'Y') ),

(ISPICKVAL(PRIORVALUE( Status__c ), "Complete") ) ,

AND

(

ISPICKVAL(PRIORVALUE( Status__c ), "Complete" ),

NOT(ISPICKVAL((Status__c, "Complete" )),

NOT(ISPICKVAL((Status__c, "Hold " ))

))

1
danimarooOP•

I'll give this a shot tomorrow/when I get time. Ended up deploying a different rule for now as my stakeholder was fine with it not being perfect. But me being me, I don't want to give up until I figure this out! It's a puzzle for sure.

2
recesshustlerkid•

I'm not even sure what I made in the above. This might actually be better:

OR (

AND (

NOT ( OR (

$Profile.Name = 'System Administrator',

$Profile.Name = 'X',

$Profile.Name = 'Y' ) ) ,

ISPICKVAL ( PRIORVALUE ( StageName ) , "Complete" ) ) ,

AND (

ISPICKVAL ( PRIORVALUE ( StageName) , "Complete" ) ,

NOT ( OR (

ISPICKVAL ( StageName, "Complete" ) ,

ISPICKVAL ( StageName, "Hold " ) ) ) )

)

2
danimarooOP•

Umm... THIS WORKED. Admittedly, it's kind of broken my brain a bit in trying to understand it, but it worked. You're amazing, thank you so much.

2