How to Create Restriction Rules in Salesforce?

I recently worked as a Salesforce Administrator for an organization that uses Salesforce to manage lead information. That organization has sales teams based on different regions, and the requirement was that each sales representative only access leads from their own region, except those leads he should not visible other leads records.

 Now, I will explain how I achieved this requirement by using Restriction Rules in Salesforce and show you how to create restriction rules in Salesforce.

The Restriction Rules are only available in Salesforce Lightning.

Restriction Rules in Salesforce

Using Salesforce restriction rules, users can see a specific set of records. The restriction rule simplifies controlling access to records with confidential or important information. Restriction rules are applied to the List View, Reports, Lookup, Related List, Search, SOSL, and SOQL Salesforce features.

When the restriction rule applies to the user, he can see only those records granted by the user via OWD(Organization Wide-Default), Sharing Rules, and other sharing mechanisms filtered by the specified criteria.

We can set restriction rules on Custom Objects, External Objects, Contracts, Events, and Tasks.

In Developer and Enterprise editions, we can create up to two restriction rules active per object, and in Performance and Unlimited editions, up to five restriction rules active per object.

Uses of Restriction Rules in Salesforce

The following are the uses of restriction rules–

  • We can filter the records based on the user and record criteria so that the user sees only the data to which he has access.
  • After applying the restriction rule, the user can access only data matching specified criteria.
  • It enhances organization and records security by allowing certain users to access specific records.

Create Restriction Rules in Salesforce

For example, in the custom object account_c, we want to display records to a specific user whose Username is XYZ. He should access only those records with an Account Priority of high.

Using the following steps, we can create a restriction rule in Salesforce.

1. Go to the Setup -> Object Manager tab. Then, search for the object name on which you want to create the restriction rule. Here, I have selected Custom Account Object.

restriction rules salesforce

2. Then scroll down to find the restriction rule option. Click on the Restriction Rule option.

salesforce restriction rules

3. You can see the Create New Rule button; click on that button.

Restriction Rules in Salesforce

4. From here, we will start to set rules for the account object.

  • Rule Name: You must enter your rule name in this field. I have set my rule name as Account Priority.
  • Full Name: This is an API name; it will populate automatically.
  • To Activate the rule, click the Is Active checkbox; you can also deactivate it.
how to enable restriction rules in salesforce

5. After entering rule detail information, you will see User Criteria.

  • User Criteria: In the user criteria, you can select users from whom you want to restrict records.
  • Field: In this field, you can select a user name, active user, alias, user ID, etc. It depends upon you. Here, I have selected a Username.
  • Operator: In this, we will select Equals Operator.
  • Type: The Type field depends upon the Field where we select the user; it can be String, Picklist, or Current User.
  • Value: Select the Value. Here, I have selected a username that we can get from user details.

We can say that we have selected a user whose Username is alexanderson123@gmail.com. Now, this user will not access records, for which we will define criteria.

what is restriction rules in salesforce

6. Next, we need to enter Record Criteria.

  • Record Criteria – In the record criteria, you can add a condition that we can select based on which field and value we want to restrict records.
  • Field: In this field, you can select a field in the same object. Here, I have selected an Account Priority.
  • Operator: In this, we will select Equals Operator.
  • Type: The Type field depends upon the Field where we select the user; it can be String, Picklist, or String. Since my selected field is picklist, the type is also picklist.
  • Value: Select the Value. Here, I have selected a High value from the picklist.

Then click on the Save button to save the restriction rule.

In the user criteria, we have defined which users who come under that criteria will not be able to access the records that we defined in the records criteria.

restriction rule

7. Here, we can see our Account Priority restriction rule has been saved.

Restriction rule in Salesforce

Proof of Concept:

Now, I will navigate to the account_c object to see the changes after applying the restriction rule. Currently, I am logged in with the Administrator profile. You can see no changes have occurred in the result; all records are displayed.

However, we applied a restriction rule for a particular user, so we need to log in with that username.

Restriction Rules in Salesforce Lightning

Now, I have logged in with the user we selected in the restriction rule and then navigated to the account_c object.

Here, you can see this user can only see those records in the list view according to the criteria that we applied in the restriction rule.

Restriction Rules in Salesforce Lightning example

This is how we can create the restriction rule in Salesforce Lightning.

Conclusion

I hope you have an idea about restriction rules in Salesforce, what they are, when we can use them, and what their uses are. Additionally, we have seen step-by-step instructions on how to create restriction rules in Salesforce Lightning.

You may like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.