I have several fields that are required upon creation. Once created, I change the record type to a read-only type, associate the record type with a read-only page layout too. However, Salesforce doesn't allow me to toggle to the read-only option in the page layout (see below image). This seems like a bug in Saleforce. Any workarounds for this scenario?
-
Page layouts are made for all kinds of scenarios. In your particular scenario, it might make sense that (once set) a required field should be read-only. In many other scenarios, it doesn't make sense. You can prevent a user from changing the field via permissions and/or triggers/flows and/or validation rules. trailhead.salesforce.com/content/learn/modules/data_security– identigralCommented Sep 22, 2023 at 18:54
-
I have added a validation rule which prevents the user from changing the value. However, this is a poor UX implementation. The entire state, i.e.., from open to complete of a Work Order can allow a user to edit fields depending on the status. Same user, same permissions, different Work Order status, different field restrictions. Are you suggesting to create permission sets that I toggle based on the status of the Work Order?– Kevin JuddCommented Sep 22, 2023 at 19:19
-
You could do the dynamic assignment of perm set if you think the cost of this solution is worth the improved UX, sure. As to the behavior of page layout, feel free to create an enhancement request on Idea Exchange.– identigralCommented Sep 22, 2023 at 19:22
1 Answer
Database required fields, be it master-detail lookups, system required, or custom required (e.g. checking required on a custom field metadata), will always show up as editable. You can't override this at the page layout level. Instead, consider making the entire record read-only by setting up your sharing settings (e.g. using criteria-based sharing) or using the Approval.lock
method to force read-only for that record for normal users.
-
Thank you for the suggestions. I'll take a look at both options to see if one works for our scenario. Commented Sep 23, 2023 at 11:25