Salesforce Certified Sharing and Visibility Architect — Question 3
Universal Containers (UC) has a custom Apex class that enforces a business process and updates opportunities. UC has noticed that fields with field-level security permission of read only on certain users’ profiles are being updates by this class.
How should the architect fix this problem?
Answer options
- A. Use the WITH SECURITY_ENFORCED keyword in the SOQL statement.
- B. Put the code in an inner class that uses the With Sharing keyword.
- C. Use the ISUpdatetable() Apex method to test each field prior to allowing update.
- D. Add With Sharing keyword to the class.
Correct answer: A
Explanation
The correct answer is A because using the WITH SECURITY_ENFORCED keyword ensures that the SOQL query respects field-level security, preventing updates to fields that should be read-only. Options B and D do not address the issue directly with respect to SOQL, while option C does not inherently enforce field-level security but merely checks for updatability.