Is it feasible to create sharing rules through apex , not manual sharing of records?
Can someone please let me know if that can be done?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
Not really. It's theoretically possible to do so, but not even Financialforce's MDAPI supports SharingRule. You would have to spend a significant amount of effort. For custom objects, you can use Apex Managed Sharing, and for standard objects, consider Apex-based manual sharing; it's relatively painless to perform in bulk, and is pretty easy to maintain. In fact, I've written a simple, but specialized, manual sharing application for my org. Depending on your needs, it's not too bad. Even then, I'd try to persuade you to look at alternative declarative options, like territory management, before you go down the dark path of automating sharing.