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
Krish NKrish N 

How to make Controlling picklist field value as read-only upon save in VF?

Hello, I've a VF page on Case object. I've custom picklist fields for Site State and Site Region. Site state is the controlling picklist field and Site region is the dependent field. Upon creating a case on VF page and saving it, I want the Site state and Site region fields to be read-only. I've tried different ways but I'm getting this error:"The dependent picklist 'Site Region' requires its controlling field 'Site State' to be present on the page." The fields show up as picklist fields. I want them to be read-only. How do I overcome it? Please help me. Thank you!
pankul guptapankul gupta
You can create an Apex Class with the lock() method to get the records locked. 
Call an event from the VF oage as soon as the record gets changed to a particular value, it will call the lock() Apex Method.
Krish NKrish N
Hello Pankul, Thank you for the suggestion. Isn't there any other way to fix it without using the code?
pankul guptapankul gupta
If in case the fields are custom or standard fields and are present on any object in Salesforce, you can follow the below link to lock a record.
https://sfdcfanboy.com/2017/04/26/7-ways-to-lock-a-record-in-salesforce/

Else, if the fields are the VF ones and no where present on the database in the Standard or custom objects, it is possible only via the code as suggested earlier.