+ Start a Discussion

Remove Access to Account based on criteria



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.


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.