function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CRMsimpleCRMsimple 

Prevent Certain Users from Changing a Picklist Value

I'm trying to create a validation rule on a picklist field that prevents users in certain roles from changing the value to a specific value.

Can anyone help with this?
JakesterJakester
What does your code look like so far? I know you're very savvy, so I'm guessing you've already tried the obvious:

Code:
and(
     user.role = "x"
    ,priorvalue(picklist,"value1")
    ,currentvalue(picklist,"value2")
)

 

CRMsimpleCRMsimple
Thanks Jake - somehow I knew you'd be a responder to this one. I was thinking I needed to use ISPICKVAL and then something with user role and ISCHANGED.  Anyhow, I didn't save my code anywhere.

With the priorvalue - it could be any of 5 other values in the picklist but there is one value that only the Contract Administrator should be able to change. How would I do this? I really don't know what the prior value would be.
CRMsimpleCRMsimple
Thanks Jake - your code actually pointed me in the right direction. I was forgetting about OR

This is what I used and it worked fine:

Code:
AND (OR (
ISPICKVAL(PRIORVALUE(Stage__c),"Closed Won - 95%"),ISPICKVAL(Stage__c,"Qualified Opportunity - 25%"),
ISPICKVAL(Stage__c,"Audit - 50%"),
ISPICKVAL(Stage__c,"Proposal - 75%"),
ISPICKVAL(Stage__c, "Closed Lost - 0%"),
NOT($UserRole.Id = " 00E70000000zZeB ")
))

 

JakesterJakester
Glad I could be of assistance - your posts have helped me several times in the past!
 
Are you planning to be at the Tour deForce this Monday by any chance?
CRMsimpleCRMsimple
No - I'm in NYC. We had ours in April. Are you in CA?

I may try and make it to Dreamforce in Nov though.

I'm sure we'll cross paths somewhere.

Thanks again!
CRMsimpleCRMsimple
Something is not right with this - it seems to be ignoring the NOT($UserRole.Id = " 00E70000000zZeB "). It only seems to be looking at the picklist values for validation.
 
Any thoughts?
Code:
AND (OR (
ISPICKVAL(PRIORVALUE(Stage__c),"Closed Won - 95%"),ISPICKVAL(Stage__c,"Qualified Opportunity - 25%"),
ISPICKVAL(Stage__c,"Audit - 50%"),
ISPICKVAL(Stage__c,"Proposal - 75%"),
ISPICKVAL(Stage__c, "Closed Lost - 0%"),
NOT($UserRole.Id = " 00E70000000zZeB ")
))

 
JakesterJakester
Could the spaces between the ID and the quotes be a problem?
CRMsimpleCRMsimple
Wouldn't that have prevented me from saving the rule?
João Paulo OrtizJoão Paulo Ortiz
But does not this formula block flow as well?