PDI · Question #140
A developer is migrating a Visualforce page into a Lightning web component. The Visualforce page shows information about a single record. The developer decides to use Lightning Data Service to…
The correct answer is A. Lightning Data Service handles sharing rules and field-level security. When using Lightning Data Service (LDS) in Lightning web components, developers benefit from its built-in security features, as it automatically enforces both sharing rules and field-level security for accessed record data.
Question
A developer is migrating a Visualforce page into a Lightning web component. The Visualforce page shows information about a single record. The developer decides to use Lightning Data Service to access record data. Which security consideration should the developer be aware of?
Options
- ALightning Data Service handles sharing rules and field-level security.
- BLightning Data Service ignores field-level security.
- CThe with sharing keyword must be used to enforce sharing rules.
- DThe isAccessible ( ) method must be used for field-level access checks
How the community answered
(50 responses)- A92% (46)
- B4% (2)
- C2% (1)
- D2% (1)
Why each option
When using Lightning Data Service (LDS) in Lightning web components, developers benefit from its built-in security features, as it automatically enforces both sharing rules and field-level security for accessed record data.
Lightning Data Service automatically respects and enforces the user's field-level security (FLS) and sharing rules, ensuring that users only see data they are authorized to access without explicit Apex controller intervention.
Lightning Data Service does not ignore field-level security; it actively enforces it to ensure data integrity and user access control.
The `with sharing` keyword is used in Apex controllers to enforce sharing rules, but LDS handles sharing rules automatically at the component level without needing an Apex controller for simple data access.
The `isAccessible()` method is used for manual programmatic field-level access checks in Apex, but LDS handles these checks automatically when accessing data directly.
Concept tested: LWC Lightning Data Service security
Source: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_lds_considerations_security
Topics
Community Discussion
No community discussion yet for this question.