Salesforce Platform Developer I (legacy) — Question 218

A developer is creating a Lightning web component to show a list of sales records.

The Sales Representative user should be able to see the commission field on each record. The Sales Assistant user should be able to see all fields on the record except the commission field.

How should this be enforced so that the component works for both users without showing any errors?

Answer options

Correct answer: D

Explanation

The correct answer is D because Security.stripInaccessible effectively removes fields that the current user does not have access to, ensuring that the component displays only the appropriate fields based on user permissions. Options A and B do not provide the necessary filtering of fields based on user roles, while option C does not specifically address the requirement to remove inaccessible fields.