Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 36 ยท Security and Access

Org-Wide Defaults, Role Hierarchy and Sharing Rules

Master Salesforce record-level security: ownership, organization-wide defaults, the role hierarchy, criteria and ownership sharing rules, teams and manual sharing.

Profiles and permission sets decide whether a user can read Opportunities in general. Record-level security decides which opportunities. It works by starting restrictive and opening access in steps. The order matters: you can only open access beyond the baseline, never close it below.

Ownership

Every record has an owner: a user or a queue (for objects that support queues). The owner always has full access to the record, including edit and delete if the object permissions allow it. Detail records in a master-detail relationship have no owner of their own.

Organization-wide defaults (OWD)

The organization-wide default is the baseline access for records a user does not own. Set it per object under Setup > Sharing Settings. The options:

OWD Meaning
Private Only the owner and users above them in the role hierarchy can see the records
Public Read Only Everyone can view; only owner and hierarchy can edit
Public Read/Write Everyone can view and edit
Public Read/Write/Transfer Also change ownership (Leads and Cases)
Public Full Access Also delete (Campaigns)
Controlled by Parent Access follows the parent record (detail of master-detail, Contact under Account in some setups)
No Access Used for some objects, such as Price Books (View Only, Use, No Access)

There are separate defaults for internal and external users, and you should keep the external default at least as restrictive as the internal one.

The golden rule: set the OWD to the most restrictive level any user needs. Then open up with the tools below. If one team must not see another's records, Private is your baseline; if everyone may read everything, Public Read Only is simpler and faster.

The role hierarchy

A role places a user in a tree, usually mirroring the company: CEO, VP Sales, Regional Manager, Sales Rep. Setup > Roles shows the tree. With Grant Access Using Hierarchies enabled for an object (the default for standard objects), users above a person in the hierarchy automatically get the same access to that person's records as they have themselves. A manager sees and, if their object permissions allow it, edits all of their team's opportunities.

Roles are about record access, not permissions: a role grants no object or field rights. A user needs a profile or permission set for that. Roles are optional, but without them hierarchical access does not exist.

Design tips:

  • Model access needs, not the org chart. Only create levels where visibility rolls up.
  • Keep the hierarchy shallow. Large, deep hierarchies slow sharing calculation.
  • Put lots of users in the same role when they should see the same data.
  • Custom objects can turn Grant Access Using Hierarchies off.
flowchart TD
    CEO["CEO"] --> VP["VP Sales"]
    VP --> E["East Manager"]
    VP --> W["West Manager"]
    E --> R1["East Rep 1"]
    E --> R2["East Rep 2"]
    W --> R3["West Rep 1"]

With Private OWD, the East Manager sees both East reps' records, the VP sees everything below, and East reps cannot see each other's records.

Python Stand-in: role hierarchy and private records

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Sharing rules

A sharing rule grants extra access to records to groups of users, beyond OWD and hierarchy. Rules can only open access. Create them under Setup > Sharing Settings, in the section of the object.

Two kinds:

  • Ownership-based: "share records owned by members of role/group X with Y". Example: share all East-owned accounts with the Support team (Read Only).
  • Criteria-based: "share records that meet criteria with Y". Example: share all Accounts where Type = Partner with the Partner Managers group (Read/Write).

You choose who receives access: public groups, roles, roles and subordinates, or queues; and the access level: Read Only or Read/Write. A sharing rule can be applied only to objects whose OWD is not Public Read/Write (no point opening what is already open).

Sharing rules take time to recalculate on large orgs: Salesforce processes them in the background, and you may see a status banner. They are best used for clear, stable groups.

Python Stand-in: ownership and criteria-based sharing rules

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Other ways to share

  • Manual sharing: an owner (or someone above, or an admin) clicks Sharing on a record to give one user or group access. It disappears if the owner changes. Needs the object to be Private or Public Read Only.
  • Teams: Account Teams and Opportunity Teams list people working a customer or deal with a role and an access level; Case Teams similar. Teams are per record or default per user.
  • Territory management: assigns accounts to territories by rules so reps see their patch regardless of ownership (Enterprise Territory Management).
  • Apex managed sharing: developers can create shares programmatically.
  • Implicit sharing: automatic rules, like seeing the parent account if you can see a child record, or the other way around for opportunities.
  • Public groups (Setup > Public Groups): sets of users, roles and other groups used in sharing rules and queues.

Putting it together

  1. Set OWD by the most restrictive need.
  2. Build the role hierarchy where visibility should roll up.
  3. Add sharing rules for cross-team needs.
  4. Use teams and manual sharing for exceptions.
  5. Check a user's access with the record's Sharing button ("Why can this person see it?") and with Login As testing in a sandbox.

Common mistakes

  • Setting OWD to Public Read/Write "to make things work" and discovering later that everything is visible.
  • Confusing roles and profiles.
  • Giving View All or Modify All to bypass a sharing problem instead of fixing sharing.
  • Creating one role per person.
  • Forgetting that changing owner can remove manual shares.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the organization-wide default define?

    OWD is the most restrictive record access; sharing tools can only open access beyond it.
  2. 2. With Private OWD, who can see a sales rep's opportunity?

    The owner and managers above in the role hierarchy see it, plus anyone granted access by sharing rules, teams or manual shares.
  3. 3. What can sharing rules do?

    Sharing rules are used to extend access to records; they cannot be more restrictive than the OWD.
  4. 4. Does a role give a user object permissions?

    Object and field permissions come from profiles and permission sets; roles drive record access through the hierarchy.

Summary

  • Records have an owner; OWD sets the baseline for others' records and can only be opened up from there.
  • The role hierarchy rolls record visibility upward; roles never grant object permissions.
  • Sharing rules (ownership or criteria based), teams, manual shares and territories add access for specific groups.
  • Choose the most restrictive OWD you can live with, then open up deliberately.

Next: Field-Level Security, Login and Authentication