I want to create a formula that restricts all profiles but two profiles to change a picklist value when the value is equal to "Apple" . If the value is equal "Apple" then the Profiles "Apple Profile" and "Melon Profile" should be the only ones to be able to change the value. Other Profiles should be able to change the value if its not equal to "Apple Profile". And they also should be able to change the value back to "Apple"

EDIT# Additionally to the part above i want records to be created only with a picklist value equal "Apple", should i create a second validation rule for that?

NOT ISPICKVAL( Stage__c , "Apple"),
NOT($Profile.Name = "Apple Profile"),
NOT($Profile.Name="Melon Profile") ))


I think what you're looking for is "validation rule" more than formula. It's true that the trigger of the validation rule is usually a formula :)

Validation rule reject record update and display an error message when formula is evaluated to true. So we have to make sure that the formula is giving true if the value of the field is "Apple" and the profile of the user making the change is neither "Apple Profile" or "Melon Profile".

Translated to formulate is:

    ISPICKVAL(Stage__c , "Apple"),
    NOT($Profile.Name = "Apple Profile"),
    NOT($Profile.Name = "Melon Profile")

EDIT: For the second need (only Apple on creation), you must ensure two or three things:

  • Do you need a different error message (I advise to have two different to make it explicit)
  • Does the two VR collide, usually we use the ISNEW() or PRIORVALUE(field) to detect creation / modification

As a side note, I forgot to mention that a better design here would be to use either a custom permission or a hierarchical custom settings

  • Custom permission will allow you to block / enable users based on the profile and/or permission set assigned to it
  • Custom settings will allow you to block / enable users based on the profile or particular user

They both work, probably using a custom permission is better as functionally it is a permission to change or not the value. And this could allow 3 levels or assignment, profile, permission set group, permission set. Salesforce also encourage us to move to permission set.

  • Sry i thought it was clear that i was talking about a formula in validation rule. The problem with the above rule is that i will be able to create a record with a picklist value that is different than "Apple". I also cant change the value back to "Apple". – mazdan Jan 19 at 16:54
  • I got it working by creating another rule where i used NEW(). Anyway thanks. – mazdan Jan 19 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.