2

I got a requirement that I need to soft delete the Accounts and Contacts. So only deleted records should be visible to System Admin. And also all Accounts and Contacts are shared based on role hierarchy.

Solution that I tried: I created a field Deleted(Checkbox) in both Account and Contact. Made OWD for Account and Contact as Private. Created Account Sharing rule and shared Accounts to all users. (Criteria id Deleted = False) Created Contact Sharing rule as same as Account. For the both Access is set to "Read-Only". Trigger before update - when Deleted field is checked it will change the OwnerId to a System Admin User. When it is unchecked it will revert back to original user.

Profiles: 1. System Admin - Both Acccount and Contact (View All, Modify All) 2. Profile1 - Both Account and Contact (Read, Create, Edit, Delete) 3. Profile2 - Both Account and Contact (Read, Create, Edit, Delete) Note: No profile has View All or Modify All access except System Admin

Role: System Admin (top level) next is Profile1 and next is Profile2(low level).

Problem facing: Record is still visible (Read-Only) even after Deleted is checked and OwnerId is changed to System Admin user for Profile1 and Profile2.

Checked there is no related child record.

I am not sure where I am missing. Please help me on this. And let me know if you need further more details.

Thanks

  • Are there other sharing rules that affect accounts and contacts? – Jagular Jul 22 '14 at 19:14
  • There is no other rule only Accounts and Contacts sharing ruler are there. – vicky90 Jul 23 '14 at 7:37
6

I would hazard a guess that you have sharing rules on the account that are causing the contacts to be shared. However, you can definitely determine why by going to a "deleted" contact, and clicking on the Sharing button. From this page, click on the Expand List button, and choose the "Why?" Link next to a user that shouldn't have access. It will list all the reasons why a user has access. You can then fix the problem based on the information presented.

"Implicit Sharing" The user has access to the contact because of a related record. You would need to remove or reassign all related child records.

"Manual Sharing" The user was explicitly shared with this contact. Delete the share.

"Sharing Rule" The user was granted access based on a sharing rule. You'll need to change the rule or change the contact so it no longer meets the rule.

"Administrator" The user's profile has View All Data. Change the permission or the user's profile.

In summation, a soft delete isn't easy to implement easily. You would have better luck cloning the contact and deleting the original, but you'll lose the association with the child records.


The Expanded Sharing List

First, click on a contact, and you'll see the following buttons:

Contact Button Section with Sharing Button indicated

If you don't see this button, then either your sharing is set to Controlled By Parent, or your layout doesn't include the button. Try editing the layout (Edit Layout is in the upper-right corner right below the tabs). If it is present on the layout, and not visible, this means that sharing is set to Controlled By Parent, which basically means you need to see the account's sharing button instead. Check your sharing settings in Setup > Security Controls > Sharing Settings. The Organization Wide Defaults (OWD) for Contacts should be set to Private.

Once you have access to the Sharing button, click on it for the Contact in question. You'll see the following screen:

Sharing Detail screen for a Contact with Expand List indicated

Click on the Expand List button, and you'll see the next screen:

Contact Access screen for a Contact record, with Why? link indicated

Finally, locate the user that has access in the list (you may use the Rolodex to filter by name, or create views). Click on the "Why?" link, and then you'll see the reasons why the user can access the contact. It will look like this:

Reasons for Sharing List

In this example, it shows that I have access to the record because I am an Administrator (Modify All Data), the Owner, and because of an Account Sharing Rule. Relationship will usually be Self or User's Manager, depending on that user's relationship.

So, in order to resolve this problem in this example contact, I would need to change the user's profile, change ownership of the record, and modify or remove the sharing rule, or even change the account the contact is associated to. Once you remove all reasons from this list, the contact will no longer be visible to the user.

  • Where is that Sharing Button available? Sorry I am new for security related stuff. Can you please explain where I can see "Why?" link. – vicky90 Jul 23 '14 at 6:42
  • @vicky90 Updated the answer with more information. – sfdcfox Jul 23 '14 at 16:21
  • Yes it worked. It has 'Read only' access in account sharing rule. Thanks a lot for a detail explanation. – vicky90 Jul 24 '14 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.