Salesforce Sharing Fundamentals

Sharing Model Fundamentals

How Salesforce Sharing Works

Salesforce uses a layered security model where sharing determines record-level access after object and field permissions are evaluated:

  1. Object Permissions: User must have Read permission on the object
  2. Field-Level Security (FLS): User must have Read permission on the field
  3. Sharing: User must have record-level access through sharing mechanisms

Key Principle: Sharing rules determine which records a user can see, not which fields they can see. Field-level security is separate and evaluated independently.

Order of Evaluation

Salesforce evaluates sharing in this order:

  1. Org-Wide Defaults (OWD): Baseline access level
  2. Role Hierarchy: Users above record owner in hierarchy
  3. Sharing Rules: Owner-based, criteria-based, territory-based
  4. Manual Sharing: Individual record sharing
  5. Apex Managed Sharing: Programmatic sharing
  6. View All / Modify All: Object-level permissions that bypass sharing
  7. View All Data / Modify All Data: System-level permissions that bypass all sharing

Important: The most permissive access wins. If any mechanism grants access, the user can see the record.

Sharing vs. Permissions Distinction

A user can have Read permission on the Account object but still not see specific Account records if sharing rules don’t grant access.

Org-Wide Defaults (OWD)

What OWD Controls

Org-Wide Defaults establish the baseline level of access to records for all users within the organization. OWD settings determine the default access level for each object before any sharing rules are applied.

OWD Settings

Private

What It Means: Only record owners and users above them in the role hierarchy can access records.

Use When:

Impact: Requires sharing rules to grant access beyond owners and role hierarchy.

Example: Cases are Private by default. Only the case owner and their manager can see the case unless sharing rules grant additional access.

Public Read Only

What It Means: All users can view records, but only owners and users above them in the role hierarchy can edit.

Use When:

Impact: Sharing rules can grant edit access, but read access is already granted to all users.

Example: Products are Public Read Only. All users can see product information, but only product managers can edit.

Public Read/Write

What It Means: All users can view and edit all records.

Use When:

Impact: No sharing rules needed for basic access. All users can see and edit all records.

Example: Knowledge articles might be Public Read/Write for collaborative editing.

OWD for Standard vs. Custom Objects

Impact on Sharing Rule Requirements

Best Practices for OWD Selection

Role Hierarchy

How Role Hierarchy Grants Access

Role hierarchy allows users higher in the hierarchy to access records owned by users below them. This structure mirrors the organization’s reporting structure.

Key Principle: Role hierarchy grants access downward - managers can see subordinate records, but subordinates cannot see manager records (unless sharing rules grant access).

Role Hierarchy vs. Sharing Rules

When Role Hierarchy is Sufficient:

When Sharing Rules are Needed:

Limitations of Role Hierarchy

Best Practices for Role Hierarchy Design

View All / Modify All Permissions

View All Permission

What It Does

View All permission grants users the ability to view all records of a particular object, regardless of sharing settings. It bypasses all sharing rules and org-wide defaults.

Scope: Object-level permission that applies to all records of the object.

Granted Through: Profiles or Permission Sets.

When to Use

Security Implications

Best Practices

Modify All Permission

What It Does

Modify All permission grants users the ability to view, edit, delete, and transfer all records of a particular object, regardless of sharing settings. It bypasses all sharing rules and org-wide defaults.

Scope: Object-level permission that applies to all records of the object.

Granted Through: Profiles or Permission Sets.

When to Use

Security Implications

Best Practices

View All Data / Modify All Data Permissions

System-Level Permissions

View All Data and Modify All Data are system-level permissions that provide access to all records across all objects in the organization.

What They Grant

View All Data

Modify All Data

When to Use

Security Implications

Best Practices and Restrictions

View All Fields / Modify All Fields Permissions

Field-Level Permissions That Bypass FLS

View All Fields and Modify All Fields are field-level permissions that bypass field-level security (FLS) restrictions.

View All Fields

Modify All Fields

When to Use

Security Implications

Best Practices

Edge Cases and Limitations

Edge Case 1: Sharing with Large Data Volumes

Scenario: Sharing rules and role hierarchy performance issues with millions of records.

Consideration:

Edge Case 2: Complex Role Hierarchy with Multiple Paths

Scenario: Users with multiple role assignments or complex role hierarchy paths causing unexpected access.

Consideration:

Edge Case 3: Sharing Rule Criteria with Formula Fields

Scenario: Sharing rules using formula fields in criteria causing performance issues or unexpected behavior.

Consideration:

Edge Case 4: View All/Modify All with Large Teams

Scenario: Granting View All/Modify All to large teams causing performance or security concerns.

Consideration:

Edge Case 5: Sharing Rule Evaluation Order Conflicts

Scenario: Multiple sharing rules matching the same record, causing unexpected access or performance issues.

Consideration:

Limitations

Q&A

Q: What is the difference between Org-Wide Defaults and Role Hierarchy?

A: Org-Wide Defaults (OWD) establish the baseline level of access for all users before any sharing rules are applied. Role Hierarchy grants additional access based on organizational structure - users higher in the hierarchy can access records owned by users below them. OWD sets the foundation; role hierarchy extends access within that foundation.

Q: When should I use Private OWD vs Public Read Only vs Public Read/Write?

A: Use Private when data is sensitive and should be restricted by default. Use Public Read Only when data should be visible to all users but editable only by owners. Use Public Read/Write when data is non-sensitive, collaborative, and all users should be able to maintain it. Start with Private and open access through sharing rules as needed.

Q: How does Role Hierarchy grant access?

A: Role Hierarchy grants access downward - managers can see subordinate records, but subordinates cannot see manager records (unless sharing rules grant access). The hierarchy mirrors the organizational reporting structure, automatically granting access based on position in the hierarchy.

Q: What is the difference between View All and View All Data?

A: View All is an object-level permission that grants access to all records of a specific object, bypassing sharing for that object only. View All Data is a system-level permission that grants read access to all records across all objects in the organization, bypassing all security mechanisms.

Q: Should I use View All/Modify All permissions?

A: Use View All/Modify All sparingly and only when absolutely necessary. These permissions bypass all sharing mechanisms and grant broad access. Consider alternatives like sharing rules or role hierarchy first. Document justification and review assignments regularly.

Q: How do View All Fields and Modify All Fields differ from Field-Level Security?

A: Field-Level Security (FLS) restricts access to specific fields based on profiles or permission sets. View All Fields and Modify All Fields are permissions that bypass FLS restrictions, allowing users to see/edit all fields regardless of FLS settings. Use these permissions with extreme caution as they may expose sensitive data.

Q: What is the order of sharing evaluation?

A: Salesforce evaluates sharing in this order: 1) Org-Wide Defaults, 2) Role Hierarchy, 3) Sharing Rules, 4) Manual Sharing, 5) Apex Managed Sharing, 6) View All/Modify All, 7) View All Data/Modify All Data. The most permissive access wins - if any mechanism grants access, the user can see the record.

Q: Can I change OWD settings after records are created?

A: Yes, but changing OWD to a more restrictive setting (e.g., from Public Read/Write to Private) may remove access that users previously had. Review sharing rules and role hierarchy to ensure users still have appropriate access after the change. Test thoroughly before making changes in production.

When to Use This Document