Why This Is Useful
Here’s a behaviour that has caught out a lot of very experienced people, including me:
When you change the owner of a record, every manual share on that record is silently deleted.
Not archived. Not warned about. Gone.
And critically, this applies to shares you created in Apex too. If you’ve written code that grants access by inserting share records, an ownership change wipes it out and your carefully built sharing model quietly stops working.
Seeing It Happen
Grab a Case record. If you don’t see a Sharing button, add it: Object Manager → Page Layouts → your layout → Mobile & Lightning Actions → drag Sharing onto the page.
Now:
1. Note the current owner. Share the record manually with another user.
2. Open the sharing hierarchy. There they are, listed with reason Manual Sharing.
3. Change the record’s owner to somebody else.
4. Open the sharing hierarchy again.
They’re gone. No prompt, no warning, no entry anywhere telling you it happened.
The reasoning is that Salesforce assumes a manual share was granted in the context of the old owner, so when ownership moves, those grants are no longer meaningful. Defensible logic. Absolutely brutal if you didn’t know about it.
Why This Bites Developers Hardest
Because Apex managed sharing on standard objects only supports the Manual row cause. So every share your code creates on Case, Account or Opportunity is a manual share, and every one of them evaporates on an owner change.
Custom objects are luckier. There you can define an Apex sharing reason, and shares created with a custom row cause survive ownership changes:
My_Object__Share share = new My_Object__Share();
share.ParentId = recordId;
share.UserOrGroupId = userId;
share.AccessLevel = 'Edit';
share.RowCause = Schema.My_Object__Share.RowCause.Project_Team__c;
insert share;Set up the reason under Object Manager → your object → Apex Sharing Reasons. It’s a small amount of extra setup that buys you sharing that doesn’t fall over.
Worth knowing that custom row causes also stop admins from casually deleting your shares through the UI, which is a nice bonus.
What To Do About It
Custom objects: use an Apex sharing reason. Problem solved permanently.
Standard objects: you can’t, so you need to handle it. Either recalculate shares in an after update trigger when OwnerId changes, or move to sharing rules and criteria based sharing where you can, since those recalculate automatically.
Everyone: if your org uses manual sharing at all, make sure whoever changes record ownership knows this happens. It’s the sort of thing that gets discovered three weeks later when somebody says “I used to be able to see this case.”
Full details in the manual sharing documentation. I’ve also got a longer post on how and when to use Apex managed sharing.
Get Coding With The Force Merch!!
We now have a redbubble store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.
Get Shirts Here!
Get Cups, Artwork, Coffee Cups, Bags, Masks and more here!
Check Out More Coding With The Force Stuff!
If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!
Youtube
Patreon
Github
Facebook
Twitter
Instagram
Salesforce Development Books I Recommend
Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Good Non-SF Specific Development Books:
Clean Code
Clean Architecture