# Apex managed sharing and share objects

*Platform Developer II Study Guide · Advanced Developer Fundamentals · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/platform-developer-ii/advanced-developer-fundamentals/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.

- Certification: Salesforce Platform Developer II
- Exam section: Advanced Developer Fundamentals
- Study guide: https://www.certifyforce.com/study-guide/platform-developer-ii

**Official exam objective:**

> Given a scenario, justify using sharing objects and Apex managed sharing.

## 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

| Fact | Detail | Source |
|---|---|---|
| Default RowCause | `Manual`; only Manual rows are deleted on owner change | [Sharing a Record Using Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm) |
| `AccessLevel` values | `Read`, `Edit`; `All` can't be granted | [Sharing a Record Using Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm) |
| Redundant share | Access not above the org-wide default fails with `FIELD_FILTER_VALIDATION_EXCEPTION` | [Sharing a Record Using Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm) |
| Apex sharing reasons and recalculation | Custom objects only | [Understanding Sharing](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_understanding.htm) |
| AccountShare RowCause on create | Only `Manual` | [AccountShare](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_accountshare.htm) |
| Org-wide default change | Runs the object's recalculation classes; removes redundant shares | [Recalculating Apex Managed Sharing](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_recalc.htm) |
| UserRecordAccess | Read-only; up to 200 record IDs; ignores restriction rules | [UserRecordAccess](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userrecordaccess.htm) |
| Omitted declaration at an Apex REST entry | Runs without sharing | [Sharing Keywords](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm) |

## Check yourself

- 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?

## Sources

- [Sharing a Record Using Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm)
- [Understanding Sharing](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_understanding.htm)
- [Recalculating Apex Managed Sharing](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_recalc.htm)
- [Use the with sharing, without sharing, and inherited sharing Keywords](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm)
- [UserRecordAccess](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userrecordaccess.htm)
- [AccountShare](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_accountshare.htm)
- [GroupMember](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_groupmember.htm)
- [Group](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_group.htm)
- [sObjects That Can't Be Used Together in DML Operations](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm)
- [Understanding Apex Managed Sharing](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing.htm)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 15 linked practice questions, and unlimited timed mock exams are included with the Platform Developer II pack (USD $19): https://www.certifyforce.com/practice-exams
