Saturday, February 18, 2023

What are sharing rules in salesforce and how to create sharing rule?

Sharing rules helps users gain access to records which they were not able to access based on OWD settings or role hierarchy setup. In simple term it simply allows greater access for particular users.

There are three types of sharing rules:

Owner-Based Sharing Rules:

An owner-based sharing rule opens access to records owned by certain users. 

For example, a company’s sales managers in region one need to see opportunities owned by sales managers in region two. 

The sales manager in region two could give the sales manager in region one access to the opportunities owned by region two team using owner-based sharing.

Criteria-Based Sharing Rules:

A criteria-based sharing rule determines with whom to share records based on field values. A criteria-based sharing rule is based on record values and not the record owners. 

For example, you have a custom object for Branch applications, with a custom picklist field named “Department.” 

A criteria-based sharing rule could share all Branch applications in which the Department field is set to “IT” with all IT professors in your organization.

Note: We cannot use Apex to create a criteria-based sharing rule. and we cannot test criteria-based sharing using Apex.

Guest User Sharing Rules:

It is a special type of criteria-based sharing rule and the only way to grant record access to unauthenticated guest users.


1) The guest user sharing rule type grants access to guest users without login credentials.

2) By creating a guest user sharing rule, you're allowing immediate and unlimited access to all records        matching the sharing rule's criteria to anyone and hence to secure your Salesforce data and give              your guest users access to what they need, it is necessary to consider all the use cases and                        implications of creating this type of sharing rule.

Now, Let us see how to create sharing rule.

1) From Setup, in the Quick Find box, enter Sharing, then select Sharing Settings.

2) Under Case Sharing Rules, click New.

Below is the image showing the details which are needed to be filled while creating sharing rule.

The image shows sharing rule screen for creating sharing rule for case object.

How to create sharing rules in Salesforce?

When we select rule type as "Based on record owner" we need to specify owner of the record whos record we are trying to share. The owner can be from anyone shown below.

Owner-based sharing rules in Salesforce

We also need to specify the users with whom we want to share the records. The users can be anyone shown below.

How to create ownership based sharing rules in Salesforce

When we select rule type as "Based on criteria" we need to specify the criteria and the the users with whom we want to share the records.

What is criteria-based sharing rules Salesforce

1 comment:

  1. Hi Farukh, as per the snapshot attached with step 3: Select which records to be shared, we don't have option like Queues, till now. Correct me, if i am wrong. Thanks..!