Posts

Showing posts from June, 2016

Utility class for Apex Sharing

Ever faced a situation where you need to share records and it cannot be achieved through standard sharing rules? In such cases, Apex Managed Sharing comes to your rescue. Let us first try to understand what sharing means. In an org where the OWD is restricitive (OWD is set other than public read/ write or public read only), you may have some requirements where you need to share records with some users.  Sharing  is the act of granting a user or group of users permission to perform a set of actions on a record or set of records. Sharing access can be granted using the Salesforce user interface and Force.com, or programmatically using Apex. To access sharing programmatically, you must use the share object associated with the standard or custom object for which you want to share. For example, AccountShare is the sharing object for the Account object, ContactShare is the sharing object for the Contact object, and so on. In addition, all custom object sharing objects are named as fo