[SalesForce] Validation rule to prevent change if field has specific value

I have a situation where I want to prevent (some) users from changing a picklist field once it has been set to a specific value.

I'm trying to create a validation rule that fires if the field is already set to that value – based on docs I thought that I should use:

ISPICKVAL(PRIORVALUE(Status__c), "Filled")

so that a validation error occurs when the picklist value is 'Filled'.

When I try this, and I try setting the picklist value to 'Filled' so that I can then try changing it, I get a FIELD_CUSTOM_VALIDATION_EXCEPTION error – never get to trying to change the value once it is 'Filled.

I expected it to allow the field to be changed to 'Filled' and then show a validation error if I try to change it to something else.

I'm hoping someone can shed some light on this.

Best Answer

You also need to check if the field was changed:

ISCHANGED(Status__c) && ISPICKVAL(PRIORVALUE(Status__c), "Filled")

This will let you change it to Filled, edit other fields while the Status is Filled, but won't allow changing away from the value.

Related Topic