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
Jina ChetiaJina Chetia 

How to make a field read-only using validation rules?


I have a field which needs to editable in one scenario and read-only in another. Can I achieve this using validation rules and how? Is there any other configuration where I can set this functionality. The condition depends on the record type, for a particular record type it should be read-only and for another it should be editable.


This should be possible either with a validation rule or page layout.  If you have page layouts specific to the record type you see if you can make the field read only on the page layout.  This may likely be the better solution.

IF you choose to try the validation rule route you should be able to use a validation formula like

RecordTypeId = "your record type ID",  ISCHANGED( your field name )

so that when it is true that the record type is the one you want the field to not be editable for AND the value in the field has been changed (edited) the formula evaluates to True and the rule is triggered.

Kent ManningKent Manning
The easiest way to do this is go to Setup \ Administration Setup \ Security Controls \ Field Accessability and select the object (accounts, contact, leads...) this is related to.  You can then view the different fields by

    "Veiw by Fields",
    "Veiw by Profiles",
    "View by Record Types". 

I would choose View by Record Types. Then when the matrix appears, select the field and the profile that you what to change (i.e., field: annual revenue for the contact manager is editable). Click on that item or "cell" and change the field level security to read only.  Go ahead and do the same for the other profiles that you wish to set to read only status.   That should do it and now it will depend on the record type whether the profile has edit or read only rights.

Hope that helps.

Anoj Singh 9Anoj Singh 9
Hi Kent,

I tried making a field read only for page layout 1 and editable for page layout2 for profile1.
I tried making the same field editable for page layout1 and editable for page layout2 for profile2
I see that when i make the field editable for page layout2, the field becomes editable for all the profiles. 
Can you please help ? Is this a limitation in salesforce ?