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
adamproadampro 

Preventing Status (picklist) from being changed from certain value

Hi,

 

I'm trying to create a validation rule to prevent the Status (which is a picklist field) from being changed once it's set to "Closed". I tried:

 

PRIORVALUE( Status__c) = "Completed"

 but apparently I can't compare the picklist value to a string like that. I also thought about using ISPICKVAL() but that takes in a field, not an actual value like PRIORVALUE would return.

 

Any suggestions?

sfdcfoxsfdcfox
ISPICKVAL( PRIORVALUE( Status__c ), "Completed" )

You nearly had it, but you still have to use ISPICKVAL.

adamproadampro

Doesn't ISPICKVAL() take in a picklist field, not a picklist value though?

sfdcfoxsfdcfox

PRIORVALUE returns the same data type as the original field type, not a string. For example, PRIORVALUE returns a number value when used on a numeric field, and returns a date value when used on a date field. Thus, it will return a "picklist value" when used on a picklist field, which ISPICKVAL can use.