Universal Containers は、サポート担当者のユーザー エクスペリエンスを向上させるために Lightning Web Components (LWC) を活用することを要求しました。LWC はビュー レイヤーとして使用され、Apex クラスにはビジネス ロジックが含まれます。
このソリューションを実装する際に開発チームが考慮すべき注意点は何ですか?
正解:A
When developing Lightning Web Components (LWC) that interact with Apex classes for business logic, it's crucial to consider how Apex's execution context affects data access and security. By default, Apex operates in system mode, which means it runs with elevated privileges, ignoring the current user's permissions and sharing rules. This behavior can inadvertently expose or allow manipulation of data that the user shouldn't access. Therefore, developers must explicitly enforce record visibility and sharing rules within their Apex code to ensure data security and compliance with the organization's sharing model. This can be achieved by declaring classes with the with sharing keyword to enforce sharing rules or by implementing explicit permission checks within the code.
Option B suggests using runAs in test classes to simulate different user contexts. While runAs is valuable for testing user-specific sharing and permissions, it doesn't directly address the need to enforce record visibility in the actual business logic.
Option C mentions using isShareable, isEditable, and isCreatable to enforce field permissions. However, these methods are not standard in Apex for enforcing field-level security. Instead, developers should use methods like isAccessible, isCreateable, and isUpdateable from the Schema.DescribeFieldResult class to check field- level permissions.
In summary, since Apex runs in system mode by default, it's imperative for the development team to enforce record visibility explicitly to ensure that users can only access data they are permitted to see.