Apex managed sharing, share objects and sharing reasons
When code is the right way to share records and when a declarative tool already fits, what a share object stores (and what it never stores), how row causes decide who can change a share and whether it survives an owner change, and how recalculation keeps Apex shares correct.
Given a set of conditions, determine how programmatic sharing supports the record access requirements.
~8 min read · 13 practice questions ·
What the exam expects
- Decide when a requirement needs programmatic sharing and when a sharing rule, guest user sharing rule or team already meets it.
- Read a share object: its fields, access levels and what it never records.
- Choose the Manual row cause or an Apex sharing reason, and predict each on an owner or default change.
- Plan recalculation and the constraints Apex shares put on the default.
- Predict how the surrounding class's sharing keyword changes the result, with the API version stated.
Key terms: share object (an object's access-control table, such as Job__Share); RowCause (why a share row exists, shown as Reason); Apex sharing reason (a developer-defined RowCause on a custom object); Apex managed sharing (shares written by code with an Apex sharing reason); recalculation class (a batch class that rebuilds Apex shares).
Key facts
- Detail
- No share object
- Detail
- Default, role hierarchy, View All/Modify All Records, View All/Modify All Data
- Detail
- Read or Edit, above the default; All is internal
- Detail
- ParentId, UserOrGroupId, RowCause
- Detail
- Manual; deleted on owner change
- Detail
- Custom objects only; kept on owner change; created in Classic
- Detail
- Modify All Data only
- Detail
- No Apex or manual shares; guest user sharing rules only
- Detail
- Redundant shares removed; recalculation classes run
- Detail
- Private can't go public while Apex uses the share entries
Sources for this section (5)
- Sharing a Record Using Apexdeveloper.salesforce.com (opens in a new tab)
- Understanding Sharingdeveloper.salesforce.com (opens in a new tab)
- Secure Guest Users’ Sharinghelp.salesforce.com (opens in a new tab)
- Recalculating Apex Sharingdeveloper.salesforce.com (opens in a new tab)
- Internal Sharing Defaultshelp.salesforce.com (opens in a new tab)
- Why does an
AccountShareexport understate who can see accounts? - When does Salesforce run an object's Apex recalculation class without anyone clicking it?
- Why can't a public site show records to visitors through a trigger that writes share rows?
- Where is an Apex sharing reason created?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Sharing and Visibility Architect pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 21 lessons of the Platform Sharing and Visibility Architect guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (13 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams