
Overview of Sharing Rules in Salesforce | Salesforce Security Guide
Hey, have you ever wondered how one can make some restrictions in the profile so that it won’t affect the other user, their privacy within the organization, and other factors? For this Salesforce provide you with a facility name as sharing rule.
Use sharing rules to extend sharing access to users in public groups, roles, or territories. Sharing rules give specific users greater access by automatically setting exceptions to organization-wide sharing settings. As with role hierarchies, sharing rules can't be stricter than the organization-wide default. It just grants better access to certain users.
You can create sharing rules based on record ownership or other criteria. Once you've selected the records you want to share, define which groups or users you want to extend access to and what level of access they have.
There are two types of sharing rules based on ownership and criteria:
Owner-Based Sharing Rules
Owner-based sharing rules open access to records owned by specific users. For example, a sales manager in one company wants to see opportunities owned by a sales manager in another region. A US sales manager can use owner-based sharing to give her APAC sales manager access to opportunities owned by the US team.
Don't forget to check out: Manual & Apex Managed Sharing in Salesforce
Criteria-Based Sharing Rules
Criteria-based sharing rules determine who to share records with based on field values. For example, let's say you have a resume custom object with a custom picklist field called Department. Criteria-based sharing rules let you share all job applications with the department field set to "IT" with all IT managers in your organization.
You can create criteria-based sharing rules for accounts, assets, campaigns, cases, contacts, leads, opportunities, work orders, and custom objects. Release standards support record types and these field types.
- Auto Number
- Checkbox
- Date
- Date/Time
- Lookup Relationship (to a user ID or queue ID)
- Number
- Percent
- Phone
- Picklist
- Text
- Text Area
- URL
Check out another amazing blog by Akash here: Integration Basics in Salesforce - Here is All You Need to Know
Points to Remember
- Criteria-based sharing rules are based on record values, not record owners. However, in a role or territory hierarchy, users higher up in the hierarchy can access the record. You can't create conditional sharing rules using Apex. Also, conditional sharing cannot be tested in Apex. Starting with API version 24.0, you can create conditional sharing rules using the Sharing Rules type in the Metadata API.
- Text and text areas are case-sensitive. For example, a criteria-based sharing rule that specifies "manager" in a text field will not share records with "Manager" in the field. To create a rule with multiple common cases of a word, enter each value separated by a comma.
- You can define up to 300 total sharing rules for each object, including up to 50 criteria-based or guest user sharing rules, if available for the object.
- Developers can use Apex to programmatically share custom objects based on record owners but no other criteria.
Responses