Advanced Developer Fundamentals15% of the exam

Apex managed sharing and share objects

When declarative sharing can't express a requirement, how to write share rows with the right RowCause and AccessLevel, keep them correct with recalculation classes, check a user's real access with UserRecordAccess, and choose the right sharing keyword for each class.

Official exam objective
Given a scenario, justify using sharing objects and Apex managed sharing.

~7 min read · 15 practice questions ·

What the exam expects

  • Justify Apex managed sharing over sharing rules and the role hierarchy for a given requirement, and spot when no share object exists.
  • Write share rows with a valid AccessLevel and RowCause, and predict what happens to them on owner and org-wide default changes.
  • Build a sharing recalculation class and design group-based shares that scale.
  • Check a user's effective access to a record with UserRecordAccess.
  • Pick with sharing, without sharing or inherited sharing for a class from how it is called.

Key terms: share object (AccountShare, MyObject__Share: the access list rows for a record), RowCause (the sharing reason, which decides who can change the row), Apex sharing reason (a developer-defined RowCause on a custom object), AccessLevel (Read or Edit granted by the row), UserRecordAccess (read-only object reporting a user's effective access).

Key facts

Default RowCause
Detail
Manual; only Manual rows are deleted on owner change
AccessLevel values
Detail
Read, Edit; All can't be granted
Redundant share
Detail
Access not above the org-wide default fails with FIELD_FILTER_VALIDATION_EXCEPTION
Apex sharing reasons and recalculation
Detail
Custom objects only
AccountShare RowCause on create
Detail
Only Manual
Org-wide default change
Detail
Runs the object's recalculation classes; removes redundant shares
UserRecordAccess
Detail
Read-only; up to 200 record IDs; ignores restriction rules
Omitted declaration at an Apex REST entry
Detail
Runs without sharing
Sources for this section (6)
  • Why is a new `Read` share rejected after an object's default changes to Public Read Only?
  • When should a service class be declared `inherited sharing` rather than left without a keyword?
  • Why can't code insert `Order_Line__Share` when Order_Line__c is a detail object?
  • Which group type keeps Apex role shares away from partner users after digital experiences are enabled?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Platform Developer II pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 28 lessons of the Platform Developer II guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (15 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Platform Developer II exam