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
Mallaurie Mulciba 22Mallaurie Mulciba 22 

Manual sharing

Hello everyone

I have a small issue with manual sharing.

I have created a custom object with a lookup relationship with Accounts.I have Account teams linked to Account.

My case is the following  : 

an account team member create a record in the custom object (a trigger change the owner of this record so he's not the owner anymore).

I remove the user from the account team member but he still can see the record because the sharing has not been removed. Is there any way to delete manual sharing  automatically in a custom object?

I also noted that when i delete the accoun team member, the account still be shared with him until i click on the sharing button and delete it. How is it possible?
AnuragGautamAnuragGautam
You should write code to delete manual sharing. 
Query : SELECT Id FROM CustomObjectName_Share

Database.delete(deleteShareRecordList,false);