---
schema_version: "1"
id: 8e326f1a8b4dc8661ac04086102df09cecd50e7f09f59510cc7d4796f66208a4
title: Custom Sharing Reason Available on Standard Objects
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/release-notes/264-0-0/rn_apex_standard_sharing_reasons.md
canonical_url: https://help.salesforce.com/s/articleView?id=release-notes.rn_apex_standard_sharing_reasons.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 08780aa7bf71cdf42e05f156d7e1767ec3b84951619e5a26dcdc64d3ff442ef8
description: Grant record access on standard objects by referencing a custom sharing reason (row cause) in Apex, the same way you do for custom objects. Previously, programmatic shares on standard objects were limited to the Manual row cause. A share that uses a custom sharing reason isn't deleted when the record owner changes, and a descriptive reason appears on the record's sharing page.
products:
  - Cross Cloud
release: "264"
---
# Custom Sharing Reason Available on Standard Objects

Grant record access on standard objects by referencing a custom sharing reason (row cause) in Apex, the same way you do for custom objects. Previously, programmatic shares on standard objects were limited to the Manual row cause. A share that uses a custom sharing reason isn't deleted when the record owner changes, and a descriptive reason appears on the record's sharing page.

**Where:** This change applies to Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

**How:** Define a custom sharing reason for a standard object that has a share object, such as `AccountShare` or `OpportunityShare`, by deploying a `SharingReason` component through the Metadata API. Then reference the reason in Apex with the same `Schema` syntax that you use for custom objects, as in `Schema.AccountShare.RowCause.Compliance_Team__c`.

```
AccountShare accShare = new AccountShare();
accShare.AccountId = '001xx000003DGa2AAG';
accShare.UserOrGroupId = '005xx000001Sv2sAAC';
accShare.AccountAccessLevel = 'Edit';
accShare.RowCause = Schema.AccountShare.RowCause.Compliance_Team__c;
insert accShare;
```

Custom sharing reasons are available only for standard objects that have an associated share object and whose org-wide default is set to Private or Public Read-Only. Objects on the detail side of a master-detail relationship, which have no share object, aren't supported. You can create up to 10 custom sharing reasons per standard object using the Metadata API.

#### See Also

- [_Apex Reference Guide_: Sharing a Record Using Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm)