Loading
Prepare for Email to Become the Default Login ExperienceRead More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Enhance Salesforce with Code
Create Apex Sharing Reasons

Create Apex Sharing Reasons

When creating Apex managed sharing, create Apex sharing reasons for individual custom objects to indicate why sharing was implemented.

Required Editions

Available in: Salesforce Classic
Available in: Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
User Permissions Needed
To create Apex sharing reasons: Author Apex
To view Apex sharing reasons: View Setup and Configuration

When creating Apex managed sharing, create Apex sharing reasons for individual custom objects to indicate why sharing was implemented, simplify the coding required to update and delete sharing records, and share a record multiple times with the same user or group using different Apex sharing reasons.

Note
Note For more information on Apex managed sharing, see the Apex Developer Guide.

Salesforce displays Apex sharing reasons in the Reason column when viewing the sharing for a custom object record in the user interface. This allows users and administrators to understand the purpose of the sharing.

When working with Apex sharing reasons, note the following:

  • Only users with the “Modify All Data” permission can add, edit, or delete sharing that uses an Apex sharing reason.
  • Deleting an Apex sharing reason will delete all sharing on the object that uses the reason.
  • You can create up to 10 Apex sharing reasons per custom object.
  • You can create Apex sharing reasons using the Metadata API.

To create an Apex sharing reason:

  1. From the management settings for the custom object, click New in the Apex Sharing Reasons related list.
  2. Enter a label for the Apex sharing reason. The label displays in the Reason column when viewing the sharing for a record in the user interface. The label is also enabled for translation through the Translation Workbench.
  3. Enter a name for the Apex sharing reason. The name is used when referencing the reason in the API and Apex. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
  4. Click Save.
 
Loading
Salesforce Help | Article