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
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))
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"))))