Restriction rule in salesforce:
The restriction rule makes certain records invisible to certain users. For example, if a list returns 50 records, The restriction rules are applied to the 25 records and the user will see only a few records.
Key Considerations:
- we can create only five restriction rules per object.
- Those rules apply to list views, lookups, related lists, reports, Search, soql, and sosl.
- Those rules enabled Custom objects, Tasks, Events, Timesheet entries, Contracts, and External Objects in Salesforce Connect.
- if a user creates an event using chatter publisher, The record name is visible in the related chatter post.
- User Can’t clone records that have a lookup to a record
- 6. Creating a restriction rule for an object doesn’t automatically restrict access to its child object. For example, if you create a restriction rule for the contract object, the access doesn’t change for notes associated with the affected contract records.
Restriction rule creation.
First of all, I did create the custom objects food__c. And then I created the two fields in the object. The fields are Customer name and non-veg.


Up next, I created the restriction rule for this object. I went to the food object and clicked the restriction rule. After that, I clicked the Create New Rule button In the object.

Up next, I wrote the rule. The rule name is Show Food and click the Active check box.

User Criteria:
Next, I chose the criteria type. The criteria type was user criteria and permission criteria. I have chosen user criteria in the rule. And then I apply the rule to the specific user. I did put the user criteria condition as the specific user Alias is vb. The criteria user will see only a given record.

Record Criteria:
Next Record Criteria, the record Criteria are selected which records the specified users are allowed to see. I did put the field name as Non_veg_c. If the Non-veg check box was not clicked, the record is shown to the user. And then I clicked the save button.

Up next, that rule was created.

Now, we will log in to that condition user, we can see that condition record only.
