+ Start a Discussion
Eric PohlabelEric Pohlabel 

Validation Rule prevent picklist change if priorvalue isnt specific values

My requirement is to only allow users with the profile of "Freelance Writer" to change the value of the Status__c picklist if the current value of Status__c is "Assigned", "Sent For Revisions by Editor", or "Sent for Revision by Client". Here is what I have so far:
 
AND
(
 $Profile.Name = "Freelance Writer",
ISCHANGED(Status__c),
NOT(ISPICKVAL(Status__c,"Assigned")),
NOT(ISPICKVAL(Status__c,"Sent for Revisions by Editor")),
NOT(ISPICKVAL(Status__c,"Sent for Revisions by Client")))
But its not quite right - seems it restricts the user from making change to Status__c even if Status__c is set to one of the acceptable values.  Do I somehow need to use PRIORVALUE for this?
 
Best Answer chosen by Eric Pohlabel
Akhil AnilAkhil Anil
Hey Eric,

So this is a use case which needs two different validation rules for a better user experience. You can create your first validation rule like this to ensure that nobody else apart from users with Freelance writer can change that field.
 
AND(
$Profile.Name <> "Freelance Writer",
ISCHANGED(Status__c)
)

You are absolutely right in saying that you need to use to PRIORVALUE function to check for the existing values. So your second validation formula would be this to check that Freelance Writer users cannot change the picklist unless it is one of the values defined below.
 
AND(
$Profile.Name = "Freelance Writer",
ISCHANGED(Status__c),
CASE(PRIORVALUE(Status__c),
"Assigned",1,
"Sent for Revisions by Editor",1,
"Sent for Revisions by Client",1,
0) = 0
)

Kindly mark it as an answer if that resolves your issue !

All Answers

Tarun Khatri (TK)Tarun Khatri (TK)
Hello Eric,

Try this:
AND
(
$Profile.Name = "Freelance Writer",
ISCHANGED(Status__c),
NOT(
OR((ISPICKVAL(Status__c,"Assigned")),(ISPICKVAL(Status__c,"Sent for Revisions by Editor")),(ISPICKVAL(Status__c,"Sent for Revisions by Client"))
)
)
)

-Thanks,
TK

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Akhil AnilAkhil Anil
Hey Eric,

So this is a use case which needs two different validation rules for a better user experience. You can create your first validation rule like this to ensure that nobody else apart from users with Freelance writer can change that field.
 
AND(
$Profile.Name <> "Freelance Writer",
ISCHANGED(Status__c)
)

You are absolutely right in saying that you need to use to PRIORVALUE function to check for the existing values. So your second validation formula would be this to check that Freelance Writer users cannot change the picklist unless it is one of the values defined below.
 
AND(
$Profile.Name = "Freelance Writer",
ISCHANGED(Status__c),
CASE(PRIORVALUE(Status__c),
"Assigned",1,
"Sent for Revisions by Editor",1,
"Sent for Revisions by Client",1,
0) = 0
)

Kindly mark it as an answer if that resolves your issue !
This was selected as the best answer
Eric PohlabelEric Pohlabel
Actually, there are users with other profiles that can and should be able to change the status - it is just the Freelance Writer profile users that should not be able to change it UNLESS it is one of those values.