2

I am running checks on fields in my Apex controller, to see if the logged in user has update access on a field before allowing an update. While logged in as Admin, when I check IsUpdateable() in my Apex controller, it returns true, even when I have explicitly removed Edit access to that field using field-level security.

Here's an isolated example that can be run in Developer Console:

System.debug(Schema.SObjectType.Account.fields.getMap().get('phone').getDescribe().isUpdateable());

Perhaps I'm missing something obvious, but shouldn't this return false if I uncheck Phone edit access in Administrator profile?

4

Administrators have the "Edit Read Only Fields" permission, so removing "Edit" from a field has no effect on fields administrators can view. They can still edit fields which could be edited as if they had Edit permission on the field. If you remove the Visible attribute as well, then isUpdatable() would be false (because they can no longer see the field at all).

|improve this answer|||||
  • Note also that this "Edit Read Only Fields" permission can't be unchecked for the standard System Admin. If you want an Admin profile that respects read-only fields (to me it's super-annoying that this permission makes read-only fields on layouts also editable) you'll have to clone the Admin and uncheck on the clone and assign that profile instead. – Charles T Feb 14 '18 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.