Exam CRT-450 All QuestionsBrowse all questions from this exam
Question 276

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?

    Correct Answer: C

    To ensure that only records accessible to the currently logged-in user are displayed, the developer should use the 'with sharing' keyword in the Apex class. This enforces that the class respects the sharing rules and record-level security of the logged-in user, ensuring that the user can only see records they have permission to view. While the 'WITH SECURITY_ENFORCED' clause is useful for enforcing field-level security in SOQL queries, the 'with sharing' keyword is specifically designed for respecting sharing rules at the class level.

Discussion
FungFamOption: C

Because this is record-level permission, "with sharing" is a correct answer.