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
Victoria KerryVictoria Kerry 

Validation rule to lock a field when the prior value something specific

Hello everyone,

I'm currently wokring on creating a validation rule where if the field "Source" is = "Task" that it can no longer change and is "locked in" so to speak. Here's my latest attempt:

AND(
    ISCHANGED(Source),
    ISPICKVAL(PRIORVALUE(Source),"Task")
)

However, when activated I can still change Source to whatever I want. Can anyone help?
Best Answer chosen by Victoria Kerry
CharuDuttCharuDutt
Hii Victoria

AND(ISCHANGED(Source),

ISPICKVAL(PRIORVALUE(Source), "Task"),

NOT(ISPICKVAL( Source, "Task")))

 please mark it as best answer if it helps 

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Victoria,

Greetings!

I think you need to add NOT operator for ISCHANGED() function as suggested in the below:

https://salesforce.stackexchange.com/questions/126253/validation-rule-to-prevent-editing-record

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Victoria KerryVictoria Kerry
Hey Shirisha,

That doesn't seem to be working for me either. I've tried: 

AND(
    NOT(ISCHANGED(Source)),
    ISPICKVAL(Source,"Task")
)

and: 

AND(
    NOT(ISCHANGED(Source)),
    ISPICKVAL(PRIORVALUE(Source),"Task")
)
CharuDuttCharuDutt
Hii Victoria

AND(ISCHANGED(Source),

ISPICKVAL(PRIORVALUE(Source), "Task"),

NOT(ISPICKVAL( Source, "Task")))

 please mark it as best answer if it helps 
This was selected as the best answer
Victoria KerryVictoria Kerry
That worked thanks! Do you know why this worked and the other examples didn't? Or what this code is "saying"?