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
streetstreet 

validation rule

I have a picklist with values

 

1) open

2) None

 

only the admin or developer Profile can select picklist value "None" then the picklist has to update the picklist, all other profiles if selects "None" sholud rise the validation error.

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
AND($Profile.Name<>"Developer",
    $Profile.Name<>"System Administrator",
    OR(
        ISNEW(),
        NOT(ISPICKVAL(PRIORVALUE(Picklist__c,"None"))
    ),
    ISPICKVAL(Picklist__c,"None"))

As a validation rule, this reads: "If the profile name is not Developer, and profile name is not System administrator, and the record is new or the prior picklist value was not None, and the current picklist value is None, then reject the edit."

 

Change Picklist__c to the name of your field. The trickery with the last two clauses allows a normal user to edit the record even if Picklist__c is set to None, so long as they were not the one to set that value.

All Answers

kiranmutturukiranmutturu

try this

 

 

IF( AND(OR($Profile.Name != 'Admin',$Profile.Name != 'developer'), ISPICKVAL(picklist_field, 'None') ), value_if_true, value_if_false)

 

sfdcfoxsfdcfox
AND($Profile.Name<>"Developer",
    $Profile.Name<>"System Administrator",
    OR(
        ISNEW(),
        NOT(ISPICKVAL(PRIORVALUE(Picklist__c,"None"))
    ),
    ISPICKVAL(Picklist__c,"None"))

As a validation rule, this reads: "If the profile name is not Developer, and profile name is not System administrator, and the record is new or the prior picklist value was not None, and the current picklist value is None, then reject the edit."

 

Change Picklist__c to the name of your field. The trickery with the last two clauses allows a normal user to edit the record even if Picklist__c is set to None, so long as they were not the one to set that value.

This was selected as the best answer
streetstreet

Thanks Kiran for the reply, i have tried using the solution you gave, when both conditions are in one IF() it was giving error if profile is admin or developer , so i have tried using two IF() statements then it worked fine.