9

When writing CRUD and FLS checks in apex I have noticed that I can check for the following:

Schema.DescribeFieldResult fieldDescribe = field.getDescribe();
fieldDescribe.accessible;
fieldDescribe.createable;
fieldDescribe.updateable;

The check for accessible is self explanatory but what is the difference between creatable and updatable since the FLS configuration on a profile only allows Read and Edit?

Profile FLS access

12

Many fields cannot be changed once populated, such as Audit Fields. Run this script:

for (SObjectField field : SObjectType.Account.fields.getMap().values())
{
    DescribeFieldResult describe = field.getDescribe();
    if (describe.isCreateable() != describe.isUpdateable())
    {
        system.debug(field);
    }
}

You should see something like:

CreatedDate
CreatedById
LastModifiedDate
LastModifiedById
IsCustomerPortal


Another circumstance where there would be a discrepancy is a Master-Detail relationship which does not allow reparenting.

Reparentable Master Detail (false)

  • Awesome - thanks for the quick answer - makes perfect sense. – Jannis Bott Nov 30 '17 at 4:24

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.