What is Apex Sharing? How to share a records via apex?
Sharing rules, let us make automatic exceptions to organization-wide defaults for particular groups of users. Sharing rules can never be stricter than our org-wide default settings. We can extend the organization-wide default setting with sharing rules. Example – If any object is private with org-wide default then we can extend the access to public read-only or public read-write with sharing rule. Salesforce provides a way by which we can create a sharing rule by the only point and click from the salesforce standard. You can set any criteria and give access to the object’s record . Example – Suppose u need to create a sharing rule for a lead object when the lead field “Is_public” become true then you can easily add these criteria and give the public access to the particular User or group etc. But some cases are there where we can’t use the standard sharing rule functionality that’s why we need to create sharing rules with apex. Let’s take a case example ...