function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mddean17mddean17 

With Apex can sharing rules be approximated using Manual shares?

Hi,
 
I want to automate Opportunity sharing with Apex and I know I can't create sharing rules programmatically. I'm wondering if I can use manual shares to approximate the behavior of a rule.
 
I mean, if I add triggers to the creation/deletion of every opportunity, managing a manual share, have I achieved the same result as the rule? Is there anything the rule does that I would be leaving out, like other kinds of recalculations? If it makes a difference, I would be managing the share for a group (role) and not individual users.
 
Any help is much appreciated.
mddean17mddean17
Just learned, in exceptional cases Salesforce permits access to rules via the API.
A_SmithA_Smith
Hi mddean17,

You should check out Apex Managed Sharing.  It was just released and is probably the right solution to your problem.

The section below in the Apex reference guide is a great place to start:

http://www.salesforce.com/us/developer/docs/apexcode/index_CSH.htm#apex_bulk_sharing.htm

Thanks,
Andrew