1

I want some fields to be updatable from apex only and want those fields as read-only on layouts for all users. Can I do it by making fields as read-only on layout?

2 Answers 2

3

Yes, I've used this technique myself.

The "read-only" flag on a page layout is only enforced when using the "save" button on the layout.

Alternatively, you could make a formula field that pulls data from the field you want to be "read only", and only include the formula field on the page layout.

3
  • only enforced when using the "save" button... and for actual API calls. Apex just ignores FLS by default.
    – sfdcfox
    Apr 6, 2020 at 16:41
  • 1
    @sfdcfox the 'read-only' flag on the page layout is separate from FLS.
    – Derek F
    Apr 6, 2020 at 16:53
  • Oops. Need more coffee, I suppose :p
    – sfdcfox
    Apr 6, 2020 at 17:09
1

I want some fields to be updatable from apex only and want those fields as read-only on layouts for all users. Can I do it by making fields as read-only on layout?

Mostly YES - the read only attribute on the page layout is distinct from the required attribute in the schema (established when the field is defined)

However, any user with Edit Read Only Fields permission will be able to edit fields marked read only on the page layout (e.g. System Administrator profile users).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .