0

I have a requirement to hide any records of an object, when the 'Status' field is set as 'Closed'. I want to hide these records from a user, even if he is the owner of the record. Is there any idea how can I achieve this?

11
  • 2
    Have you considered changing the owner when the record becomes Closed, assuming you are using sharing rules?
    – Phil W
    Commented Dec 11, 2020 at 11:07
  • 3
    Record ownership is at the core of SF record access capabilities and I don't think you would be able to restrict a record owner from at the least being able to view the record. Create a custom field to capture owner info for reporting purposes and upon status change to Closed, consider copying the current owner into the custom field and change the actual owner of the record. Additionally, use sharing rules.
    – arut
    Commented Dec 11, 2020 at 11:27
  • 1
    There could be few things you would need to consider with reference to reports and dashboards, but I'm sure there will be workarounds. Also, if you take this approach, don't end up taking a single user as new owner for all relevant records because this would lead to data skew in future.
    – arut
    Commented Dec 11, 2020 at 11:27
  • 1
    @PhilW Both criteria- and owner-based sharing rules could be used, but only after the record owner is changed. You might know that the SF record sharing and access model is all about opening up access from the most restrictive access to least restrictive access. And, the SF model doesn't exclusively facilitate restricting access. This requirement sounds like a request to restrict the access to the record owner without changing the owner, which is not possible IMO.
    – arut
    Commented Dec 11, 2020 at 11:48
  • 1
    Most of my sharing experience is based on Ownership and Roles combined with Apex Sharing. The latter is, of course, an option. Drop OOTB owner-based sharing and replace with Apex creation and/or deletion of sharing records based on owner and status fields.
    – Phil W
    Commented Dec 11, 2020 at 11:52

1 Answer 1

3

Summarizing the key points from the comments as an answer (so those looking for an answer don't have to go thru all the comments).

Record ownership is at the core of SF record access capabilities and none of the record access or sharing mechanisms (such as OWD, Object permissions, Role hierarchy, Sharing rules etc.) in Salesforce can be used to modify the access the record owner implicitly has on his/ her records. So, there is no way to remove access on a record for its owner. SF sharing & access model works on the principle of opening up access from the most restrictive access to least restrictive access and there is no explicit way to restrict access for specific users (after opening up access for a group of users).

Workaround to this problem is to create a custom field and copy the original owner field into this custom field for reporting purposes, if needed. Change the owner via apex when the record hits a certain required condition or, as pointed out by @PhilW, use apex managed sharing (after revoking the ownership). Other existing sharing rules and role hierarchy will have to be checked so the user doesn't get access to the record thru one of these after his/her record ownership is revoked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .