I have an 'X' check-box field on 'Y' custom object which cannot be edited once the record is created. How to achieve this requirement. Thanks in advance
-
1Do you mean that someone can edit the value on the intial creation screen, but then can never edit the field after that?– Nick CCommented Nov 16, 2015 at 5:57
-
1with standard layout you can't make that read only though you can write a validation rule which can prevent edit.– HimanshuCommented Nov 16, 2015 at 6:15
-
@NickCook Yes, once the record is created no one should be able to edit it so, I would like to show the field as read-only/output value.– VenkyCommented Nov 16, 2015 at 6:28
-
Thanks @Himanshu for your reply is there any other possible way other than validation rule like hiding field from layout after creation of record.– VenkyCommented Nov 16, 2015 at 6:32
-
besides Himanshu's answer, you would need to use a VF page that overrode the standard Edit page and another VF page using apex:detail and jQuery that overrode the standard detail (View) page– cropredyCommented Nov 16, 2015 at 17:31
Add a comment
|
1 Answer
There are two option to complete this requirement.
- Write a validation rule/Trigger which will prevent for value change in that field
Standard layout doesn't give that flexibility where you can make field read only after it's creation so in that case you can follow below approach if you want to show field as read only.
- Create two record types and make first record type as default
- Create two different page layout per record type one with checkbox without read only and second page layout with checkbox read only.
- Once you save the record change the record type of record from first to second. it will change the page layout of the record and you will see field as read only.