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
Manikanth Goud Rajamouni 1Manikanth Goud Rajamouni 1 

how to make a field readonly in salesforce through validation rule

I have User lookup field in opportunity which is manditory,if we save the  opportunity record  with stage='closed won',and selecting one user in User field and now if  we try to edit opportunity record the User lookup field should be read only with the previous value saved .
Amit VaidyaAmit Vaidya
Hi Manikanth,

Please try this in your validation rule.

AND(ISCHANGED(StageName), NOT(BlANKVALUE(PRIORVALUE(StageName)))

Thanks,
Amit
sharathchandra thukkanisharathchandra thukkani
If you want the read only field you need to change the record type of the opportunity record using workflow when it is closed and assign a page layout to the opportunity closed record type where your User lookup field field will be read only.