Siirry sisältöön

Testing and Troubleshooting What Was Taken Away

Tämä sisältö ei ole vielä saatavilla valitsemallasi kielellä.

Module 7 of 7 in the chapter Taking Access Away: Restriction and Scoping Rules, chapter 16 of Securing Salesforce: Sharing and Visibility. Each module stands on its own.

The question this module answers: A restriction rule takes access away quietly, with no share row to show for it. How do you prove it does exactly what you meant, and how do you find it when it’s the reason someone can’t see a record?

Everything in Part 2 left evidence: a row in the share table, with a row cause. A restriction rule leaves none (module 1). So testing it isn’t optional, and it isn’t something you check once. In my video I checked the small airport rule the way I check everything: I logged in as the pilot, in his own browser, and looked.

In chapter 13 I gave you three users for every test: one to own, one to share with, one you’re not sharing with. You prove the positive, and you prove the negative (chapter 13, module 1). A restriction rule needs the same habit, turned around, because it takes away instead of giving.

Take the contracts rule from module 2: everyone without “See All Contracts” sees only their own region’s contracts. You need three users:

  • A user the rule applies to: a sales rep in the West region.
  • A user it doesn’t apply to: someone on the contracts team, with the permission.
  • The administrator, who holds View All Data and sees everything regardless (module 1).

And you need two records: a West contract, and an East contract the West rep can reach through the sharing model, so the rule is the only thing standing between them.

Then:

  • The positive. The West rep opens the West contract. The rule didn’t take away what it should leave.
  • The negative. The West rep can’t find the East contract: not on the page, not in a list view, a lookup, a report or search. That’s the rule working.
  • The control. The contracts team member sees both. If they can’t, the rule applies to more people than you meant.

Here are the three users and the two records, one test at a time. Notice where every arrow after the first one lands: on the East contract, the record the rule is there to hide.

Three users, two records Three users, two records: testing a restriction rule. Three users on the left: a West sales rep, whom the rule applies to; the contracts team, with See All Contracts, whom the rule doesn't apply to; and the administrator, with View All Data, who goes past the rule. Two records on the right: a West contract, and an East contract that is shared with the rep. Step 1, the positive: the West rep sees the West contract. Step 2, the negative: the West rep's arrow to the East contract fails, hidden by the rule. Step 3, the control: the contracts team sees the East contract. Step 4: the administrator sees it too. Footnote: prove the positive, prove the negative, then check the users the rule shouldn't touch; the East contract is shared with the rep, so the rule is the only thing hiding it. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-21", "id": "DGM-SVA-RR-08", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.5.0", "theme": "stevetecharc 1.4.0"} THREE USERS TWO RECORDS West sales rep the rule applies Contracts team See All Contracts: the rule doesn't apply Administrator View All Data: goes past the rule West contract region: West East contract region: East · shared with the rep 1 · sees it 2 · hidden by the rule 3 · sees it 4 · sees it Prove the positive, prove the negative, then check the users the rule shouldn't touch. The East contract is shared with the rep, so the rule is the only thing hiding it. HOW TO READ IT can see the record © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Then test the people and records around the rule, because that’s where rules go wrong:

  • A user who matches no rule and shouldn’t: an integration user, an agent’s user, someone with an empty region. They see everything the sharing model opened (module 3).
  • A user who could match two rules, if the object has more than one. Salesforce won’t tell you; only your test will (module 3).
  • A record with an empty or wrong field value. It vanishes for everyone the rule applies to (module 2).
  • The records hanging off it: notes, files and other child records, which the rule doesn’t touch (module 4).
  • The side doors on activities: calendar subjects, Chatter posts, search shortcuts (module 4).

Three of those fit in one picture, on the same users and records as the one above. The rep still can’t open the East contract, but the note on it is another matter.

The side effects The side effects of a restriction rule. Users on the left: the West sales rep, whom the rule applies to, and an integration user who matches no rule. Records on the right: a new contract with an empty region, the East contract, hidden from the rep by the rule, and a note on the East contract, which is a child record. Step 1: the West rep's arrow to the new contract fails; an empty region matches nothing, so the contract is gone for everyone the rule applies to. Step 2: the integration user sees the East contract, because no rule applies to it; check that you meant it. Step 3: the rep's arrow to the note on the East contract is not hidden by the rule, because a rule on contracts doesn't change access to their notes. Footnote: a rule tests the record's own fields, for the users it matches; the user it doesn't match, the record whose field is empty, and the records hanging off it are yours to test. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-21", "id": "DGM-SVA-RR-09", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.5.0", "theme": "stevetecharc 1.4.0"} THE USERS AROUND THE RULE THE RECORDS AROUND THE RULE West sales rep the rule applies Integration user matches no rule A new contract region: empty no region East contract region: East · hidden from the rep A note on the East contract a child record 1 · matches nothing: gone 2 · sees it: no rule applies 3 · not hidden by the rule A rule tests the record's own fields, for the users it matches. The user it doesn't match, the record whose field is empty, and the records hanging off it are yours to test. HOW TO READ IT not hidden: check that you meant it © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

The quickest way to see what the rule leaves is to be the user. An admin can log in as them, as you did in chapter 4 (chapter 4, module 6): “To help troubleshoot user issues, admins can log in to a Salesforce org or Experience Cloud site as the employee user experiencing the problem” (Log In as Another User (opens in a new tab), Salesforce Help, checked 2026-11-26).

Check every place the rule applies, not just the record page: list views, lookups, related lists, reports, search. And try an old link to a hidden record: “If a user has a link to a record that is no longer accessible after a restriction rule is applied, the user sees an error message” (Restriction Rules (opens in a new tab), Salesforce Help, checked 2026-11-26). That error is your proof the rule reached the record.

Chapter 13 showed how System.runAs lets a test become a user, so “that user’s sharing rules and object-level and field-level permissions are enforced” (chapter 13, module 3). The pages I checked don’t say whether a restriction rule applies inside a runAs block. Don’t assume it either way: write one test with a matching and a non-matching record, run it in your org, and keep it.

What the pages do say is the part that matters most: “Restriction rules aren’t applied for code executed in System Mode” (Restriction Rule Considerations (opens in a new tab), Salesforce Help, checked 2026-11-26). So for every Apex class, flow and integration that reads the object, ask how it runs. If it runs in system mode, the rule doesn’t protect anything it returns to a user. Chapter 17 is about writing that code safely.

When a user can’t see a record: is it a rule?

Section titled “When a user can’t see a record: is it a rule?”

Now the other side: someone says “I can’t see it,” and you suspect a rule. Chapter 13 put restriction rules last in its walk-through (chapter 13, module 5). Here’s how to settle it quickly.

The query says yes, the screen says no. “The UserRecordAccess object doesn’t consider whether a user’s access is blocked due to a restriction rule.” (Restriction Rule Considerations). When UserRecordAccess says they have access and they can’t open the record, that’s your first sign.

The Sharing Hierarchy can tell you directly. On the record, the Sharing Hierarchy lists who has access, and “In editions that support restriction rules, this list can include users who don’t have access due to a restriction rule.” Click View on the user: “If a restriction rule blocks access to the record, a message is shown to confirm that access is blocked” (Viewing Which Users Have Access to Your Records in Lightning Experience (opens in a new tab), Salesforce Help, checked 2026-11-26). Chapter 13 module 4 walks through the tool.

Then find which rule. Look at each active rule on the object. Whose user criteria matches this user? There should be exactly one. Then read the record criteria against the record: is the field empty, or different from what you expected?

And rule out the look-alikes. Two things look like a restriction rule and aren’t. If the user can open the record from a list view but not find it by search, that’s probably search crowding: search limits the matches before it applies the user’s access (module 5). If a list view or report shows fewer records than expected but the record opens fine, check whether Filter by scope is selected: that’s a scoping rule (module 6).

When a user can't see a record: is it a rule? When a user can't see a record: is it a rule? A user can't see a record they should, and you suspect a rule. First question: does the Sharing Hierarchy show their access as blocked? If yes, it's a restriction rule: find the one whose user criteria match them. Next: does the record open from a list view but not from search? If yes, it's search crowding, not a rule, module 5. Next: is Filter by scope selected? If yes, it's a scoping rule: switch the view, module 6. Next: does UserRecordAccess say no access? If yes, it's the grants, chapter 13 module 5. Otherwise, check the field the rule tests: an empty value matches nothing. Footnote: UserRecordAccess can say yes while a restriction rule says no. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-20", "id": "DGM-SVA-RR-07", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "flow/decision 0.1.0", "theme": "stevetecharc 1.4.0"} A user can't see a record they should and you suspect a rule Does the Sharing Hierarchy show access blocked? A restriction rule: find which whose user criteria match them? Opens from a list view, but not from search? Search crowding, not a rule module 5 Is Filter by scope selected? A scoping rule: switch the view module 6 Does UserRecordAccess say no access? It's the grants chapter 13, module 5 Check the field the rule tests an empty value matches nothing yes no yes no yes no yes no UserRecordAccess can say yes while a restriction rule says no. HOW TO READ IT a step the step that matters most a question an answer yes goes right to an answer; no goes down to the next question © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Here’s what that looks like on a lab record a restriction rule hides. The list says Read Only; View says blocked.

Bench Route Stops, Stop PHX-002, Sharing Hierarchy, All Users, 2 items: Bench Dispatcher One, Read Only; the owner, Full Access, name greyed out.

The list counts Bench Dispatcher One as Read Only (Salesforce, a record page in a Partner Developer Edition org, screenshot, November 2026). Full size

The same user's View: Relationship, a restriction rule blocks access to this record; Bench Route Stop Access, None.

View tells the truth: a restriction rule blocks access (Salesforce, a record page in a Partner Developer Edition org, screenshot, November 2026). Full size

A rule depends on fields, values and users that change under it. Run the three users again whenever:

  • A rule is added, changed or deployed to another org (module 3).
  • A picklist value, custom permission or field a rule uses is added, renamed or deleted (module 2).
  • People move: a reorganization, a new region, a new permission set group.
  • A new integration, flow or agent starts reading the object.

Keep the test with the rule, as chapter 13 module 4 keeps the evidence: who you tested as, which records, and what each one saw. That’s what you’ll show an auditor, and what the next admin will run before they change it.

Test knowledge. Know how to prove a restriction rule: a user it applies to, a user it doesn’t, and an administrator with View All, against a record that matches and one that doesn’t. Know that UserRecordAccess doesn’t consider restriction rules, that the Sharing Hierarchy can list users a restriction rule blocks and confirms it with a message, that rules aren’t applied to code in system mode, and that a link to a record hidden by a rule shows an error. Know the look-alikes: search crowding, and a scoping rule with Filter by scope selected. A likely area, not a known question.

  • The test for each rule: which three users, which two records, and every place it applies.
  • Which code, flows, integrations and agents read the object, and whether any run in system mode.
  • Where the test lives, and who runs it again when fields, values, permissions or people change.
  • The support path for “I can’t see it”: the Sharing Hierarchy first, then the rule’s criteria, then the look-alikes.

Beyond the exam: what AI changes. Add the agent’s user to the three, as a fourth. Ask the agent, in its own words, for the record the rule should hide, and check it says it can’t find it. Then ask for something that would need that record to answer, and check the answer doesn’t leak it anyway, through an action that runs in system mode or through a related record the rule doesn’t touch. Chapter 20 covers agents.