Restriction Rules in Salesforce with Example

This post will walk you through the implementation of Restriction Rules in Salesforce with an example. This is a newly added feature in Salesforce. Certainly one of the most straightforward yet most efficient and most needed functionality is finally at our hands.

Let’s see what Restriction Rules are all about.

What is a Restriction Rule?

Restriction Rules let us enhance the security by allowing certain users or users with specific permissions to access only specified records. It is mainly used to prevent users from accessing sensitive data or information.

When should we use Restriction Rules?

Restriction Rules are basically used when we want users to see only a specific set of records. Ideally, we use Organization-Wide Defaults (OWD) to restrict access to records. Then, we can open up the access using Role and Hierarchies, Sharing Rules, Apex Managed Sharing, Manual Sharing, etc.

But what if we want to restrict users to see a few of the records that are shared/visible due to the above Sharing Settings? In that case, we can use Restriction Rules in Salesforce to further add the criteria for users to restrict access to sensitive data that they are not supposed to see.

Restriction Rules in Salesforce
Restriction Rules in Salesforce

How to create Restriction Rules?

First, go to Object Manager -> Select applicable Object -> Click on Restriction Rules from the left panel.

Click on New Rule and provide Rule Name, Description, etc.

Then, we need to specify the User Criteria based on either one of the below Criteria Type:

  • User Criteria: Uses fields of current user record to determine if the Rule will be applicable.
  • Permission Criteria: Uses the selected Custom Permission to determine if the Rule is applicable.

Finally, we need to provide the Record Criteria which will be used to filter the records that will be displayed for the particular user that matches the User Criteria.

Also Read:

Below is the sample Restriction Rule in Salesforce that I created for the demonstration of this implementation:

Sample Restcition Rule in Salesforce
Sample Restcition Rule in Salesforce

Based on this rule, if the current User has a Nickname as nikstest, then that user will be able to see only the active Subscribe records.

Below is the list of All records which were visible BEFORE creating a Restriction Rule:

BEFORE the rule is created
BEFORE the rule is created

Below is the list of All records which were visible AFTER creating a Restriction Rule:

AFTER the rule is applied
AFTER the rule is applied

This behavior of Restriction Rules is similar to filters in the List Views, except that it’s Permanent for those particular users who satisfy the User Criteria.

Which Objects are available?

Restriction Rules in Salesforce are only available for:

  • Custom Objects
  • Contracts
  • Events
  • Tasks
  • Time Sheets
  • Time Sheet Entries

Restriction Rules are not available for External Objects.

Restriction Rules are applied only to the following Salesforce features:

  • List Views
  • Related Lists
  • Reports
  • Lookups
  • Search
  • SOQL
  • SOSL

Also Read:

If you don’t want to miss new implementations, please Subscribe here.

That is all from this post. I recommend checking the official Salesforce documentation about the considerations while using Restriction Rules in Salesforce with an example here.

If you want to check more standard implementation in Salesforce, you can check it here.

Leave a Comment