apex – For SOQL queries, can “WITH USER_MODE” safely replace “WITH SECURITY_ENFORCED”?
We are recommending developers to use WITH USER_MODE and avoid using the WITH SECURITY_ENFORCED
In fact at some time in the future it’s likely we may retire WITH SECURITY_ENFORCED
The WITH USER_MODE supports lots of new innovations like restriction rules, scoping rules and any other security operations for data access and CRUD/FLS that may be added by the platform in future, so it’s sort of future proof. Also handles complex security use cases better.
Also it supports SOSL and polymorphic queries and performs far better than using the WITH SECURITY_ENFORCED.
The WITH USER_MODE can handle CRUD/FLS for fields in where clause in SOQL or for fields used in relationship query or polymorphic lookup.
You can find more information about why you should prefer WITH USER_MODE and avoid WITH SECURITY_ENFORCED in the latest talk at TrailblazerDX 2023 conference and the link to view the talk is shared below
Read more here: Source link
