Development questions
What is the difference between WITH SECURITY_ENFORCED and Security.stripInaccessible()?
WITH SECURITY_ENFORCED: checks FLS/CRUD for fields in the SELECT (and some parents) and throws aSystem.QueryExceptionif any are inaccessible. It does not check fields in WHERE/ORDER BY.Security.stripInaccessible(): does not throw; it removes inaccessible fields from records (or the whole record) and lets you continue, also usable for DML sanitization.
apex
SObjectAccessDecision d = Security.stripInaccessible(AccessType.READABLE, [SELECT Id, Phone FROM Account]);
List<Account> safe = d.getRecords();
Use stripInaccessible when you want graceful degradation; use WITH USER_MODE (newer) for strict enforcement.
soqlsecurityfls
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?