Salesforce Developers Blog

Protect Apex Shares: Custom Row Causes on Standard Objects

Avatar for Larry TungLarry Tung
Avatar for priceprice
Explore two Winter ’27 enhancements that simplify record sharing in Salesforce. Learn how to preserve manual shares during ownership changes and use custom row causes on standard objects to reduce workarounds and improve sharing management.
Protect Apex Shares: Custom Row Causes on Standard Objects
October 20, 2026

For over a decade, standard objects didn’t support custom row causes. When you needed to share a record from Apex, you had to use the Manual row cause. . Since Salesforce deletes Manual shares when a record’s owner changes, you had to write workarounds.

Two enhancements remove the need for those workarounds. The Keep Manual Shares when Transferring Records setting is available now. Custom row causes, also called Apex sharing reasons, are rolling out for standard objects in the Metadata API and will reach all orgs by the end of October. In this post, we’ll look at Keep Manual Shares on Record Transfer and Custom Row Causes for Standard Objects.

Keep manual shares on record transfer

Availability: Available now.

In Sharing Settings, turn on Keep Manual Shares when Transferring Records. Manual shares then survive ownership changes, and you can remove any workarounds you built for this.

The Sharing Settings page showing the Keep Manual Shares when Transferring Records option.

Custom row causes for standard objects

Availability: Rolling out now; all orgs will have it by the end of October.

Apex managed sharing requires an Apex sharing reason. Salesforce stores it in the RowCause field of each share record; we call it a custom row cause in this post. You can now define one on a standard object the same way you do on a custom object. For details, see Sharing a Record Using Apex.

The following example defines an On-Call Expert sharing reason on Case, using the Metadata API:

1<?xml version="1.0" encoding="UTF-8"?>
2<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3    <sharingReasons>
4        <fullName>On_Call_Expert__c</fullName>
5        <label>On-Call Expert</label>
6    </sharingReasons>
7</CustomObject>

Deploy it with a package.xml that lists Case.On_Call_Expert__c as a SharingReason member.

Then you can use it in Apex:

1CaseShare share = new CaseShare();
2share.CaseId = caseId;
3share.UserOrGroupId = userId;
4share.CaseAccessLevel = 'Edit';
5share.RowCause = Schema.CaseShare.RowCause.On_Call_Expert__c;
6insert share;

You can also assign a custom row cause in Flow.

A custom row cause keeps your Apex shares separate from users’ manual shares, and Salesforce doesn’t delete them when the owner changes. In the share table, admins can see why each user has access. Because each reason is separate, you can update or delete the shares for one reason without touching the others. Unlike the Keep Manual Shares setting, a custom row cause doesn’t change how users’ manual shares behave. In November, you’ll be able to manage custom row causes in AIforce and Setup with Agentforce.

Conclusion

Winter ’27 gives you two ways to keep shares when a record’s owner changes.

  • If you don’t create shares in code, turn on Keep Manual Shares when Transferring Records. It’s one org-wide setting.
  • If code, a Flow, or an integration creates shares on standard objects, switch to a custom row cause. Your shares survive owner changes, stay separate from users’ manual shares, and show why each user has access.

You may need only one of them. Start by reviewing the code that creates CaseShare, AccountShare, or other standard share records.

Resources

About the author

Larry Tung is the Product Manager for the Sharing team, where he’s working on the next generation of user access features and protecting sensitive data. When Larry isn’t working, he enjoys playing sports and board games with his kids and reading.

Peder Rice is a software engineer on the Sharing team, where he works on record access at scale. He enjoys traveling with his kids in search of hidden corners the guidebooks miss.

More Blog Posts

The Salesforce Developer’s Guide to the Summer ’26 Release

The Salesforce Developer’s Guide to the Summer ’26 Release

Summer ’26 developer highlights: Hosted MCP Servers, LWC State Managers, Apex user-mode defaults, Agentforce Mobile SDK, and CLI updates with code examples.June 08, 2026

Building AI Automations with Prompt Builder Structured Outputs

Building AI Automations with Prompt Builder Structured Outputs

Learn how the Prompt Builder Structured Outputs feature delivers reliable, parseable JSON for Flow and Apex by eliminating hallucinated fields and the need for custom parsing code.April 02, 2026

【TDX Tokyo 2026】Lightning MiniHack Live ファイナリスト座談会: 初代チャンピオンと挑戦者たちが語る「最速」の舞台裏と AI 時代の実装力

【TDX Tokyo 2026】Lightning MiniHack Live ファイナリスト座談会: 初代チャンピオンと挑戦者たちが語る「最速」の舞台裏と AI 時代の実装力

本記事では、TDX Tokyo 2026 で開催された Lightning MiniHack Live のファイナリスト の皆さんをお招きした座談会の様子をお届けします。なぜ挑戦したのか、「最速」をどう作り込んだのか、そして AI 時代に「実装力」はどこへ向かうのか。世代もバックグラウンドも異なる 4 名の言葉には、これから挑戦するみなさんへのヒントが詰まっていました。August 31, 2026