0

We use a Customer Community to dispatch Work Orders to partners. The partners use Customer Community Plus licenses. We share the Work Order using a community sharing set, but we cannot share the account the same way - because multiple partners might work on multiple work orders to the same account and therefore all partners need access to the same account.

Because our organization wide external sharing model for Accounts is "Private", I must manually share these accounts. I tried a trigger-based solution that inserts AccountShare, but unfortunately, I cannot get it to work: The shares get created, the partner as access to the community, and approximately 15 to 30 minutes later the partner cannot access the account any more. When inspecting AccountShare in the developer console, the respective share is gone.

I understand, that "Manual" shares are highly volatile and I need to account for use cases like owner change. I did, and still the shares magically disappear. Can anybody tell me, why?

1

When the owner changes, sharing calculations are performed sometime around the final commit, long after your triggers. This is what causes your shares to disappear despite your best efforts. You would need something like a future method or queueable to persist those changes correctly. That said, you might consider using Account Team Members, which tend to work well for your use case (probably).

3
  • Thank you for this insight. As I understand it, I would not have this issue with custom objects, because I could simply add an "Apex Sharing Reason" that would persist owner changes? So the better architecture for sharing accounts (or any standard object) would be to create an AccountTeamMember for every partner user instead of adding an AccountShare? Jul 23 '20 at 8:55
  • @J.Lietzau Correct, standard objects have a lot of built-in functionality, and so usually have to be handled differently. We we Account Teams in our org, and it works well. I suggest you give it a try and see if it helps.
    – sfdcfox
    Jul 23 '20 at 13:59
  • I tried it, and it does not work. Same as "AccountShares", salesforce simply wipes the Account Team Members after a couple of minutes. Any idea, why? Dec 17 '20 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.