Record Sharing in Salesforce: Manual, Automated & Apex Sharing Explained
Salesforce is all about data access control, ensuring that the right users see the right data at the right time. Whether you’re sharing records with a teammate or automating visibility to an entire department, Salesforce provides flexible and secure sharing mechanisms to get the job done.
In this blog, we’ll dive into the three primary ways to share records in Salesforce:
📌 Methods of Record Sharing
- Manual Sharing (Using the Sharing Button)
- Automated Sharing (Using Sharing Rules)
- Apex Sharing (Via Apex Code)
🧑💻 1. Manual Sharing – One Record at a Time
Manual Sharing is perfect when you need to share an individual record with a specific user or group.
✅ When to Use:
- Quick ad-hoc record access
- Temporary collaboration
- Sharing sensitive records selectively
⚙️ Prerequisite:
The Organization-Wide Default (OWD) for the object must be set to Private. Only then will the “Sharing” button appear on record detail pages.
🔧 Steps to Share a Record Manually
Let’s say you’re logged in as a Development User and want to share an Account record with a Testing User (Read-Only access).
- Go to the Accounts tab and open the target record
- Click the “Sharing” button
- Click “Add”
- Select the user (e.g., Testing User)
- Choose Access Level → Read Only
- Click Save
🔍 Observation:
When the Testing User logs in, they can now view the record—but cannot edit or delete it.
🔁 Sharing with Multiple Users? Use a Public Group!
Manual sharing with many users can be repetitive. Instead, create a Public Group.
📂 What is a Public Group?
A Public Group is a named collection of users, roles, or other groups. Once created, it can be reused to share records to multiple users at once.
🛠️ Steps to Create a Public Group
- Go to Setup
- Expand Manage Users → Click Public Groups
- Click New Group
- Name the group (e.g., Hyderabad Sales Group)
- Add members: Users, Roles, or other Groups
- Click Save
🔎 Public Groups live in the Group object (ID starts with OOG), and their members are tracked in the GroupMember object.
🤖 2. Automated Sharing – Using Sharing Rules
Manually sharing each record is tedious. Salesforce solves this with Sharing Rules, which automate access to records based on certain conditions.
✨ Two Types of Sharing Rules:
- Owner-Based Sharing Rules – Share records based on their owner
- Criteria-Based Sharing Rules – Share records based on record field values
🔍 Use Case:
Create a Sharing Rule to grant Read-Only access to Account records for the Hyderabad Sales Group when:
- Rating = Hot
- Industry = Healthcare
- Active = Yes
- Ownership = Private
⚙️ Steps to Implement Criteria-Based Sharing Rule
- Go to Setup
- Navigate to Security Controls → Click Sharing Settings
- In the Sharing Rules section, click on the object (e.g., Account Sharing Rules)
- Click New
- Name the rule: Grant Account Access to Hyderabad Sales Group
- Select Rule Type → Based on Criteria
- Set the conditions:
- Rating = ‘Hot’
- Industry = ‘Healthcare’
- Active = ‘Yes’
- Ownership = ‘Private’
- Define the users to share with:
- Choose Public Groups
- Select Hyderabad Sales Group
- Choose the access level: Read Only or Read/Write
- Click Save
✅ Once saved, the rule automatically grants access to any matching records—no manual steps required.
🧩 3. Apex Sharing – Programmatic Flexibility
When you need complex, dynamic, or highly customized sharing, you can use Apex code to create Apex Sharing Rules.
This allows:
- Conditional logic beyond standard sharing rules
- Sharing in batch processes
- Revoking access based on business events
(Note: We’ll cover Apex Sharing in detail in a future post!)
🎯 Wrapping Up
Choosing the right record sharing approach depends on your use case:
Scenario | Best Method |
Share one-off records manually | Manual Sharing |
Share records based on logic (e.g., industry, region) | Sharing Rules |
Share using code or dynamic logic | Apex Sharing |
🔐 Salesforce Record Sharing – Best Practices (Quick Guide)
- Start Restrictive – Set OWD to the most private setting, then open access as needed.
- Limit Role Depth – Keep role hierarchy flat for better performance.
- Go Declarative First – Use sharing rules before Apex sharing.
- Group Wisely – Use Public Groups/Queues instead of individual users.
- Minimize Ownership Changes – Reduces sharing recalculations.
- Use Apex Sharing Sparingly – Only for complex, custom logic.
- Avoid Manual Sharing – Hard to manage at scale.
- Batch Recalculations – Don’t overuse recalculateSharingRules().
- Enable the Sharing Button – Helpful for debugging access issues.
- Audit Regularly – Use logs and tools to monitor access.
By understanding and using these three powerful sharing strategies in Salesforce, you’ll be able to tailor data visibility to match your organization’s structure—securely and efficiently.