콘텐츠로 이동

Taking Access Away: Restriction and Scoping Rules

이 콘텐츠는 아직 번역되지 않았습니다.

Chapter 16 of Securing Salesforce: Sharing and Visibility, Part 3: Beyond the Company and Beyond the Record. New to the course? Start with chapter 1.

Count the ways to share in this course, and almost every one of them opens records. Org-wide defaults, the role hierarchy, rules, teams, territories, implicit sharing, code, sharing sets. In class I put restriction rules this way: this is the first element that lets us narrow access down.

This chapter is about the two tools that narrow. A restriction rule is strict: it filters what the sharing model opened, everywhere the user looks, for good. A scoping rule is soft: it changes what people see first, and they can switch it off. Built the same way, doing very different jobs.

And because a restriction rule leaves no row in the share table, the chapter ends where it has to: with how to prove it works, and how to find it when it’s the reason someone can’t see a record.

  • Open, then narrow. A restriction rule filters what sharing opened, permanently, in list views, lookups, reports, search and queries; View All, Modify All and code in system mode go straight past it.
  • Spend the few shots where nothing else works. Filtering the children of a master-detail, a lock on external objects, and a flag on the record such as soft-deleted or confidential.
  • Two filters: the user and the record. User criteria or a custom permission decide who; the record criteria decide what they keep; equals only, so compute one field when the real rule needs an AND.
  • One rule per user, two to five per object. Salesforce doesn’t stop two rules matching one person, so the design has to.
  • Tasks, events and contracts are where rules matter most, because defaults can’t make them private, and where subjects and names can still show through side doors.
  • A rule runs every time the user looks. On external objects it’s the only lock on the row and it loads the other system; on large objects, test the filter first.
  • A scoping rule is a filter, not a lock. A nice to have for focus, never for “must not see.”
  • Prove it, and look for it. Three users and two records; the Sharing Hierarchy shows a blocked user when UserRecordAccess says yes.

Here’s where the chapter starts: where a restriction rule sits, and what goes past it.

Where a restriction rule sits Where a restriction rule sits. First, sharing opens records: defaults, the hierarchy, rules, teams and the rest. Then the restriction rule narrows them to only the records that match, always. It applies everywhere the user looks: list views, lookups, reports, search, SOQL and more. Below the rule, straight past it: View All, Modify All, and code in system mode. Beside that: it isn't in the share table, and UserRecordAccess doesn't see it. Footnote: a restriction rule writes no share row; it filters what sharing opened. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-20", "id": "DGM-SVA-RR-01", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.5.0", "theme": "stevetecharc 1.4.0"} SHARING OPENS THE RULE NARROWS What sharing opens defaults, hierarchy, rules, teams… Restriction rule only records that match · always Everywhere they look list views, lookups, reports, search, SOQL… Straight past it View All, Modify All, code in system mode Not in the share table and UserRecordAccess doesn't see it then narrowed applied in A restriction rule writes no share row: it filters what sharing opened. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

And the one that holds the chapter together: the two rules side by side.

A restriction rule and a scoping rule, side by side A restriction rule and a scoping rule, side by side. Restriction rule, strict, a lock: always on; takes access away; applies everywhere, in list views, lookups, records, reports, search, SOQL and SOSL; in Enterprise, Performance, Unlimited and Developer editions; for custom and external objects, quotes, contracts, tasks, events and time sheets. Scoping rule, soft, a filter: the user chooses Filter by scope; it changes what shows first and hides nothing; it applies to list views and reports when chosen, and to SOQL; in Performance, Unlimited and Developer editions; for custom objects, accounts, cases, contacts, events, leads, opportunities and tasks. Footnote: if the requirement says "must not see," a scoping rule isn't the answer. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-20", "id": "DGM-SVA-RR-06", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison 0.5.0", "theme": "stevetecharc 1.4.0"} Restriction rule strict: a lock Always on Takes access away Everywhere: list views, lookups, records, reports, search, SOQL, SOSL Enterprise, Performance, Unlimited, Developer Custom and external objects, quotes, contracts, tasks, events, time sheets Scoping rule soft: a filter The user chooses Filter by scope Changes what shows first, hides nothing List views and reports when chosen, and SOQL Performance, Unlimited, Developer Custom objects, accounts, cases, contacts, events, leads, opportunities, tasks If the requirement says "must not see," a scoping rule isn't the answer. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Seven modules, each standing on its own.

  1. Open, Then Narrow: Where a Restriction Rule Sits. After all of sharing; everywhere the user looks; what goes straight past it; no row, and a query that doesn’t know; which objects and how many; when it’s the right tool; where restriction rules shine.
  2. Designing the Criteria: the User and the Record. User criteria or a custom permission; the record criteria and Salesforce’s examples; values filled by automation; the rules of the form; the contracts team.
  3. One Rule per User, Two to Five per Object. Two shots, or five; Salesforce doesn’t check; designing so only one can match; moving rules between orgs.
  4. The Hard Objects: Activities and Contracts. Why the defaults can’t do it; competing teams on one account; confidential services; what still shows through; contracts and their child records.
  5. External Objects and Performance. The only lock on the row; the other system’s load; search on purpose; testing the filter on large objects; and when search can’t find a record the user can open (search crowding).
  6. Scoping Rules: a Filter, Not a Lock. Where they apply; when they help; letting users choose their scope; the details; turning one off.
  7. Testing and Troubleshooting What Was Taken Away. Three users, two records; testing as the user; Apex and system mode; is it a rule; test again when something changes.

Then check what stuck with the study guide.

  • Whether the sharing model should open less in the first place, before a restriction rule narrows it.
  • For each rule: the object, who it applies to and through what, the one field it tests, and the automation that keeps that field filled.
  • How rules on one object are kept apart, and who is meant to match none.
  • Who holds View All or Modify All, and which code runs in system mode, on every object a rule protects.
  • For activities, contracts and external objects, what still shows through, and what the other system can take.
  • Where a scoping rule helps people focus, and that nobody mistakes it for security.
  • The test for each rule, kept with the rule and run again when fields, values, permissions or people change.

Beyond the exam: what AI changes. A restriction rule is a real guardrail for an agent’s user, in queries and search, as long as the agent’s actions run as the user and not in system mode. A scoping rule is no guardrail at all. Before an agent goes live, put its user on the overlap check and into the test as a fourth user, and ask it for the records a rule should hide. Chapter 20 covers agents.

Each module lists its own sources. Two to start with:

Next: Sharing When Writing Apex: Secure Code