0

I am attempting to find best practices around mixed SObject security. When I am using DML statements I validate either through "with SECURITY_ENFORCED" or through {SObject}.SObjectType.getDescribe().isDeletable(). What are the best practices when working with a List for checking DML permissions before inserting or updating?

1 Answer 1

2

The new, modern way to do this is Security.stripInaccessible. This automatically checks all field level access, record level access, and object level access. It takes all the guesswork out of using describes and other security checks. You can still use WITH SECURITY_ENFORCED if you want an all-or-nothing approach, but Security.stripInaccessible will give you the ability to successfully resolve a query and still maintain data security.

2
  • I feel like I just learned about Security_Enforced... Thank you for the insanely quick response.
    – Agamemnon
    Commented Apr 9, 2021 at 13:03
  • 1
    @Agamemnon I literally didn't even have time to use the SOQL function once before the Security class came out. It's so much more functional than just WITH SECURITY_ENFORCED; they clearly took some time thinking about that method.
    – sfdcfox
    Commented Apr 9, 2021 at 13:41

You must log in to answer this question.

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