I want to mark a single field as read only when I clone a record. I am not able to find which page layout is in action when we clone a record
2 Answers
Another possible way to accomplish this is to use a validation rule.
While validation rules are not well suited to handle things of the form "prevent all fields from being edited except for fields x, y, z", validation rules can fairly easily handle locking down single fields.
In this case, using the ISCLONE()
function in conjunction with ISCHANGED()
should accomplish what you're looking to do.
One way I can think of to accomplish this would be to assign a different recordtype to the cloned record. With the different recordtype, you can associate a new page layout to it (one that has your target field marked as read-only).
Of course, that either requires you to be cloning via Apex (so you can modify the recordtype prior to insertion), or having a trigger in place that checks isClone()
(a method of the sobject class)