Gå til indhold

the User and the Record

Dette indhold er ikke tilgængeligt i dit sprog endnu.

Module 2 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 has two filters: who it applies to, and what they can still see. How do you write each one so the rule does exactly what you mean?

In class I put it simply: you have two filters, one on the user and one on the record. The user filter decides whether the rule kicks in for this person. The record filter decides which records they keep. Get either one slightly wrong and the rule either misses people it should catch or hides records it shouldn’t.

Here’s the part I love. You get to use things about the user that sharing never could. A sharing rule shares with roles and groups. A restriction rule can look at any field on the user record.

Salesforce gives you two ways to say who (Create a Restriction Rule (opens in a new tab), Salesforce Help, checked 2026-11-26):

  • User criteria. For a subset of users, such as a role, profile or department, choose User Criteria and a field on the user. “Set the Type field as Current User when the rule applies to the currently logged-in user.”
  • Permission criteria. For users with or without a custom permission, choose Permission Criteria. “To filter records for users with the custom permission, set the Boolean value to True.” For users who don’t have it, set it to False.

In my demo I chose user criteria. I made a checkbox on the user, “is small airport only,” and the rule kicks in for anyone with it checked. That’s quick to show, and it works.

But think about who checks that box. A field on the user is data. Anyone who can edit users can change it, and an import can change it. A custom permission, given through a permission set, is something your admins already assign and review like every other permission. For a rule that protects anything sensitive, I’d lean to permission criteria. For a rule driven by something that’s already true about the person, their role, their profile, their department, user criteria fits.

Notice the False option too. A custom permission called “See All Contracts,” with the rule set to False, applies the rule to everyone without it. That’s often the clearer design: everybody is narrowed, and the exceptions are the people you’ve deliberately given the permission.

The record criteria is the filter itself. “Under Record Criteria, select which records the specified users are allowed to see” (same page). In my demo: airport type equals small airport. Anyone the rule applies to sees small airports, and nothing else.

Salesforce’s example scenarios show the patterns you’ll use most (Restriction Rule Example Scenarios (opens in a new tab), Salesforce Help, checked 2026-11-26):

  • Only a record type. A role in the user criteria, and the record type’s name in the record criteria: “allows the designated users to see only the records that have a specified record type.”
  • Only their own. “Allows users with the designated profile to see only the tasks that they own”: the task’s owner, as a user, equals the current user.
  • Only their own role’s, or profile’s. Events “owned by users that have the same role,” by comparing the owner’s role with the current user’s role. The same works for profile.
  • A field on the record that matches a field on the user. “Allows high-volume users to see only the contracts where the user’s department matches the contract’s department.” Note the high-volume users: a restriction rule reaches the cheap seats from chapter 15 too.
  • A list of values. “The record criteria contains strings separated by a comma. ID values are also supported.”

The last two show the real power. The record criteria can compare the record with the person looking at it, so one rule covers every department, every role, every owner, without a rule for each.

That department example comes with a warning worth reading twice: the custom field “must have the appropriate value set through Apex, Process Builder, workflows, or flows” (same page). If the value you filter on isn’t already on the record, you put it there with automation, and the rule is only as good as that automation.

It’s the same move as chapter 8’s region field (chapter 8, module 3): if the thing you share on isn’t on the record, add a field and keep it filled. For a restriction rule it matters more, because a record with the wrong value doesn’t get shared with too few people. It disappears for everyone the rule applies to.

The criteria look like a little query, but they’re much simpler than one (Restriction Rule Considerations (opens in a new tab), Salesforce Help, checked 2026-11-26):

  • Equals, and only equals. “Restriction rules support only the EQUALS operator. The use of AND and OR operators isn’t supported. The use of formulas isn’t supported.” One field, one comparison.
  • A list stands in for OR. “Comma-separated ID or string values are supported in the Record Criteria field.” To include one value that has a comma in it, “surround the value with double quotes” (Create a Restriction Rule).
  • The data types. “boolean, date, dateTime, double, int, reference, string, time, single picklist.” No multi-select picklists, no long text.
  • Short IDs. “If you reference IDs in the record criteria, use 15-character IDs instead of 18-character IDs.”
  • Another object’s field, not the parent’s. “You can reference another object’s field using the Record Criteria field,” but “you can’t reference fields on the object’s parent. For example, if you’re creating a rule for the Task object, the record criteria can’t reference a field on the parent Activity object.”
  • Say what kind of owner. “When you reference the Owner field, you must specify the object type in your syntax.” On an event the owner can be a user or a queue, “but queues aren’t supported in restriction rules,” so you write Owner:User.
  • A missing link means no access. “If a restriction rule’s record criteria uses a lookup field and the related record doesn’t exist, access isn’t granted.”
  • Don’t delete what the rule uses. “If you delete a custom picklist value used in a restriction rule, the rule no longer works as intended.”

Put “equals only” and “no AND” together and you get the design habit for this whole chapter: if the real rule has an AND in it (“contracts in my region and not marked confidential”), you don’t fight the form. You compute one field that says it, with automation, and the rule checks that field.

The anatomy of a restriction rule The anatomy of a restriction rule. Who it applies to: user criteria, a field on the user such as role, profile, department or a checkbox; or permission criteria, a custom permission, true or false. What they still see: record criteria, one field equals a value or a comma list, such as record type, the owner as a user, a field that matches the user's own, or a field on another object. The rules of the form: equals only, with no AND, OR or formulas; 15-character IDs; no fields on the parent; a missing lookup means no access. Footnote: if the real rule needs an AND, compute one field with automation, and filter on that. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-20", "id": "DGM-SVA-RR-02", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison 0.5.0", "theme": "stevetecharc 1.4.0"} Who it applies to user or permission criteria A field on the user: role, profile, department, a checkbox Or a custom permission, true or false What they still see record criteria One field equals a value, or a comma list Record type, or the owner as a user A field that matches the user's own A field on another object The rules of the form simpler than a query Equals only: no AND, OR or formulas 15-character IDs No fields on the parent A missing lookup means no access If the real rule needs an AND, compute one field with automation, and filter on that. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Here’s how I’d put it together for something more serious than airports. A company keeps its customer contracts in Salesforce. Most of the sales team should see only the contracts for their own region. The contracts team sees them all.

  • Who: permission criteria, a custom permission “See All Contracts,” set to False. The rule applies to everyone who doesn’t hold it. The contracts team gets it through a permission set.
  • What: record criteria, the contract’s region field equals the current user’s region, a field on the user kept up to date with the territory changes.
  • The automation: a flow that sets the contract’s region from its account, so there’s never a contract with an empty region that vanishes for the whole sales team.

And then the question module 1 left you with: who holds View All on contracts, and which code reads contracts in system mode? Those people and those processes see every region, whatever this rule says.

Test knowledge. Know the two filters: user criteria (a field on the user, compared with the current user) or permission criteria (a custom permission, true or false), and record criteria (what the user can still see). Know the form’s limits: EQUALS only, no AND, OR or formulas; comma-separated lists of strings or IDs; 15-character IDs; the supported data types; no fields on the object’s parent; Owner:User for owner fields, since queues aren’t supported; a lookup to a record that doesn’t exist grants no access; deleting a picklist value a rule uses breaks it. A likely area, not a known question.

  • For each rule, whether it applies through a user field or a custom permission, and who controls that field or permission.
  • Whether the rule narrows everyone except the people who hold a permission, or only the people who hold one.
  • The single field the record criteria will test, and the automation that keeps it filled, so no record vanishes because a value is missing.
  • Where the real requirement has an AND, the computed field that says it in one value.
  • That picklist values and IDs a rule depends on are documented, so nobody deletes or changes them by accident.

Beyond the exam: what AI changes. An agent’s user is a user like any other, so it matches a rule’s user criteria, or doesn’t, by the same fields and permissions. Decide on purpose which rules should apply to each agent’s user, and give it the custom permissions or field values that say so. An agent user left out of a rule’s criteria sees everything the sharing model opened. Chapter 20 covers agents.