I have a role hierarchy in my org. The hierarchy is :

  • a. Sales Director
    • a1. Direct Sales
      • a1.1 SME Sales Coordinator
    • a2. Indirect Sales

Also, i have a partner user who creates Account records in the partner community. By using sharing rules, i want the SME Sales Coordinator (role) to have view access to these Account records, if:

1. The Account's record type = 'Individual' or Account's record type = 'Corporate'


2. The Account record was created by a partner user (group of partner users). Not a specific partner 
  (i don't want a partner's user specific id).

The sharing rules types, are record owner based or criteria based. I need a way to combine those two types. Because, i want to apply record owner sharing rules based on specific criteria and i cannot see something obvious from UI.

Do you have any ideas, how to approach it?

Thank you in advance

  • Not sure what how you define groups but if can get a boolean stamped on created account record which specifies if the record was created by group of partner users according to the definition you have then you can use only criteria based sharing rule.
    – manjit5190
    Sep 23, 2020 at 19:29

1 Answer 1


If the click based sharing rule page wont allow it, it may still be possible with Apex.

For example someone could enhance the relevant ‘before insert’ and ‘before update’ contexts to always upsert *__share records when/as needed , and delete *__share records when/as needed to effectively maintain the kind of advanced sharing pattern you are chasing after.

Be sure to try-catch or otherwise handle any potential exceptions, per best practices. For example:

exceptions, including object access exceptions can occur when using apex managed sharing. See :“Sharing Considerations” > “Apex Triggers and User Record Sharing”, for more on that, and as of Sept. 2020:

“If a trigger changes the owner of a record, the running user must have read access to the new owner’s user record if the trigger is started through the following: API Standard user interface Standard Visualforce controller Class defined with the with sharing keyword”

“If a trigger is started through a class that’s not defined with the with sharing keyword, the trigger runs in system mode. In this case, the trigger doesn’t require the running user to have specific access.”

SOURCE= https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_understanding.htm

Also see 1.https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm%20and%20 2. https://salesforce.stackexchange.com/a/112034/10073

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .