Quote from a Salesforce article
"Scoping rules let you control the records that your users see based on criteria that you select. You can set up scoping rules for different users in your Salesforce org so that they can focus on the records that matter
to them. Users can switch the set of records they’re seeing as needed."
As above, scoping rule is not similar to the restriction rule, where the restriction rule prevents the user to access certain records, while scoping rule is just to scope for the user to focus on a set of records, so users can still access all other records that they can access according to the sharing rules settings.
As of now (Winter '23 release), scoping rules are available for custom objects, Account, Case, Contact, Lead, Opportunity, Event, and Task. It is available in Unlimited or Performance edition, if you use Unlimited or Performance edition but do not see scoping rules available in the objects mentioned above, reach out to Salesforce support to enable it.
When a scoping rule is applied to a user, the data that the user sees in list views and reports are filtered by the criteria you set.
Follow this article to create scoping rules, there are 2 options for User Criteria when creating a scoping rule:
- Criteria Type = User Criteria
- Criteria Type = Permission Criteria
User Criteria, select a field in the user object as the criteria of who the rule will apply, unfortunately, you can't use the field of the child object such as Profile Name or Role Name at this moment, so just using their Id will work, and there is no option to set multiple criteria and use AND logic.
On the Record Criteria, set criteria to filter records that fit into the scoping. Here you can use the field from a child object, but no option to set multiple criteria and use AND logic.
Permission Criteria, this uses custom permission, then defines the custom permission under the permission set, then assigns users to that permission set.
Once the custom permission and the permission set are created, you can use the custom permission in scoping rule.
Make sure the scoping rule is active and let us see how it works in the list view and report. In the list view Filter by Owner, select Filter by scope.
The same for the report filter, select Filter by scope.
The result of the above list view and report is based on the record criteria defined in the scoping rule. As you see that "Filter by Scope" is just an option, meaning your users can select other filters option too.
Known Issue: if the User Criteria contain space, this will not be saved by the scoping rule, and this cause the scoping rule will not to run for the users defined, check out this.