While developing an Apex class with custom search functionality that will be launched from a Lightning Web Component, how can the developer ensure only records accessible to the currently logged in user are displayed?
A.
Use the WITH SECURITY_ENFORCED clause within the SOQL.
Ensures field-level security and sharing rules are enforced in SOQL queries.
Prevents unauthorized records or fields from being accessed or displayed.
Why Not Other Options?
B and C:with sharingandinherited sharingenforce record-level access but do not handle field-level security.
D:without sharingignores sharing rules, which would display all records regardless of user permissions.
[References:Security in SOQL:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_with_security_enforced.htm, , ]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit