function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MiddhaMiddha 

Remove Access to Account based on criteria

Hi,

 

Background: I have Account OWD set to private and number of sharing rules defined which gave number if users access to Account records. I have a checkbox called "Inactive" on Account. 

 

Requirement: I want that if an Account is marked as inactive, the account (and related records) should not come in any search results, for any user other then System Administrator.

 

Solution that I can think of is if I can update the Account owner to System Admin and remove any kind of sharing it has. But i can only delete any manual sharing. Rule based sharing cannot be deleted from APEX.

 

Can anyone suggest any other solution?

 

Thank you.

matermortsmatermorts

I think your idea of reassigning to the system admin will work, as long as the system admin is at the top of the role hierarchy or is outside of the hierarchy altogether. It doesn't even necessarily need to be the system admin; just has to be a user at the top of the hierarchy.

 

Setup a workflow with a field update, to change owner to sysadmin when inactive is changed to true, and you're golden.