With the help of the given below methods we can share records in Salesforce:
Role hierarchy:
- Whenever a user is added to a role, the user above the current user in the hierarchy of roles will have access to reading the records and inheriting the permissions.
- Follow the steps for role hierarchy: Go to Setup → find manage users' → roles → set up roles → click on ‘add role’ → provide name and click on save.
OWD:
- OWD(Organization-Wide Defaults) allows you to give permissions to the organization-wide and to define baseline setting for the organization. It is also helpful in defining the user’s accessibility level to the user where a user can see other user’s records.
- OWD settings can be Public Read Only, Private, Public Read, and Write.
- Follow the steps for OWD: Go to Setup → find the Security Controls → click on ‘sharing settings’ → click on ‘Edit.
Manual sharing:
- Manual sharing is sharing a single record/file to a single user or group of users through manual access.
- We can see a button for manual sharing on the detail page of the record and it can be seen only when the OWD setting is private.
Criteria based sharing rules:
- If we want to share records based on conditions such as share records with a group of users with the criteria of the country is India.
- Follow the steps for criteria-based sharing rules: Go to Setup → security controls → sharing settings → select the object and provide name and conditions then click on save.
Apex sharing:
- Sharing object is available for each and every object in Salesforce. For example, the Account object’s share object is AccountShare.
- By using Apex, if we want to share the records then we have to create a record to the shared object.