Learn how Salesforce architects can ensure users maintain access to custom object records shared through Apex managed sharing, even when the record owner changes. Discover the best practices and techniques to preserve record visibility and maintain data security in your Salesforce org.
Table of Contents
Question
What should a Salesforce architect recommend to make sure that users that gained access to a custom object record through Apex managed sharing do not lose access to it when its owner is changed?
A. Use “With Sharing” keyword to make sure record visibility will be considered.
B. Create a specific Apex Sharing Reason for the custom object.
C. Create a new record in _Share object with RowCause “Manual”.
D. Use “runAs” system method in Apex classes to enforce visibility.
Answer
B. Create a specific Apex Sharing Reason for the custom object.
Explanation
When using Apex managed sharing to grant users access to custom object records, it’s crucial to create a specific Apex Sharing Reason for that custom object. This ensures that the sharing entries created through Apex managed sharing are associated with a distinct sharing reason.
By creating a dedicated Apex Sharing Reason, the sharing entries remain intact even if the record owner is changed. The custom sharing reason preserves the visibility granted through Apex managed sharing, preventing users from losing access to the records they were previously granted access to.
Other options, such as using the “With Sharing” keyword, creating manual sharing entries, or using the “runAs” system method, do not provide the same level of protection against ownership changes. They may result in users losing access to records when the owner is modified.
Therefore, the recommended approach for a Salesforce architect is to create a specific Apex Sharing Reason for the custom object to ensure that users maintain access to records shared through Apex managed sharing, even when the record owner is changed.
Salesforce Certified Sharing and Visibility Architect certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Salesforce Certified Sharing and Visibility Architect exam and earn Salesforce Certified Sharing and Visibility Architect certification.