Skip to content
Back to articles

Security · Record access · Practical guide

Use restriction rules to reduce Salesforce record visibility

Filter an already-shared custom object by region with a Salesforce restriction rule, then test the security boundary and known bypasses.

A sharing rule opens access. A restriction rule works in the other direction: after organization-wide defaults, role hierarchy, sharing rules, teams, and other sharing mechanisms have granted access, the restriction rule filters that visible set. This makes restriction rules useful when a supported object is broadly shared for collaboration but a particular group must see only the records relevant to it.

Restriction rules do not grant object permission, field access, or record access. Treat them as an additional record-level filter, not as a replacement for a complete sharing model.

Concrete example: regional service requests

Assume a fictional custom object named Service_Request__c has a single-select picklist named Region__c. The User record has a corresponding single-select Support_Region__c picklist. Existing sharing lets support agents read many service requests, but policy says regional agents should see only requests whose region matches their user record.

The intended rule is simple: users in the regional-agent population can see a Service_Request__c record only when Service_Request__c.Region__c equals $User.Support_Region__c. Use your actual fields and governance policy; the names in this article are examples.

1. Prove the object and edition are supported

Salesforce documents restriction rules for Lightning Experience in Enterprise, Performance, Unlimited, and Developer editions. Supported targets include custom objects, external objects, quotes, contracts, events, tasks, time sheets, and time sheet entries. They are not a general filter for every standard object.

Before designing the rule, inventory current organization-wide defaults, sharing rules, groups, teams, and elevated permissions. The result of the restriction rule is the intersection of records the user can already access and records that match the rule. If the user cannot access a record before the rule, the rule cannot make it visible.

2. Define a non-overlapping user population

Create a custom permission such as Apply Regional Service Request Restriction, add it to a narrowly assigned permission set, and use that permission as the rule's user criterion. Here the custom permission does not grant broader record access; it identifies the users whose results should be filtered. Document that unusual purpose so another administrator does not treat the permission as an entitlement.

Salesforce recommends that only one restriction or scoping rule per object evaluate to true for a given user. Salesforce does not validate this for you. If two active rules match the same user, only one is observed, which can expose records the administrator expected the other rule to hide. Map every active rule and its population before activating a new one.

3. Create the rule in Object Manager

  1. In a sandbox, open Setup → Object Manager → Service Request → Restriction Rules, then create a rule.
  2. Give it a descriptive label and API name, such as Regional Service Requests and Regional_Service_Requests.
  3. For the user criterion, choose permission criteria and select Apply Regional Service Request Restriction = True.
  4. For the record criterion, choose Service_Request__c.Region__c, the Equals operator, the Current User type, and $User.Support_Region__c.
  5. Save it inactive first if your change process permits, then activate only during the controlled test window.

The builder exposes the choices available for the selected fields. Restriction rules support only the Equals operator; formulas and AND or OR combinations are not supported. Salesforce supports selected field types, including boolean, date, date/time, number, reference, string, time, and single-select picklist. Design a simple, durable criterion rather than trying to reproduce complex sharing logic in the rule.

4. Prepare representative test records

Create sandbox users and records that make the boundary visible:

Confirm the agents can see both regional records under the current sharing model before activation. That baseline distinguishes a working restriction rule from a pre-existing sharing difference.

5. Test every place users find records

Activate the rule in the sandbox and test as the actual representative users, not only as an administrator. For the West agent, the West record should remain visible and the East record should become unavailable. Repeat in a list view, lookup, related list, report, global search, direct record URL, and an API or query tool that authenticates as the agent. Salesforce applies restriction rules across record access surfaces including reports, search, SOQL, and SOSL.

Then repeat as the East agent and the supervisor control. Test record creation, edits that change the region, and any automation that assigns the region. A blank lookup used by a record criterion does not grant access, so include null and incomplete-data scenarios in the test plan rather than assuming they fail open.

6. Test the known bypasses deliberately

Users with View All on the object or View All Data can still view all records regardless of restriction rules. Users with the corresponding Modify All permissions retain broader view, edit, and delete access. Code executing in system mode is also not constrained by restriction rules. Review permission sets and permission set groups for these permissions, and test integrations or automation under their real execution context.

The UserRecordAccess object also does not account for records blocked by a restriction rule. If it reports access but the user cannot open the record, check the object's restriction rules before concluding that sharing recalculation failed.

Deployment, monitoring, and rollback

  1. Move the rule through your normal change process. Salesforce supports change sets and unlocked packages for restriction rules.
  2. Re-check any org-specific IDs used by criteria; role, profile, and record type IDs can differ across environments.
  3. Activate during a monitored window and sample list views, reports, lookups, search, API queries, and direct links as affected users.
  4. Watch support tickets and integration errors for missing records. Record the rule owner and review date.
  5. For immediate rollback, deactivate the rule and confirm the formerly hidden test record is visible again under the existing sharing model.

Do not use a production administrator account as the only acceptance test. Elevated permissions are specifically capable of bypassing the control you are trying to verify.

Important limitations

Salesforce record visibility troubleshooting · Smarter sharing with organization-wide defaults and sharing rules

Official Salesforce references

Published October 12, 2026. Official Salesforce references checked on this date. Object names, fields, users, and records are examples; verify edition support, permissions, automation context, and data architecture in your own org.

Browse all articles