2

I am working on a customer community portal, and would like to setup a Cases view to embed in the webpage which shows the contact/user who is logged in any case for the account they are associated with, regardless of owner?

If I use the "My Cases" option on the view I publish to the community portal, any case they created shows up, but sometimes a customer service agent might make the case, or it might be created by Email, so we can't use that ownership function exclusively.

If there's another way to approach this, please advise, or if I can provide more information to be helpful.

Thank you in advance!

Shamir

  • You're going to need to get the community user's contact Id so you can get their related AccountId, then query for all of the Cases related to that Account. The issue you're going to encounter though is sharing on Cases. That will likely be the most difficult issue to sort out. – crmprogdev Nov 28 '16 at 21:52
  • Which licence type is it - Customer Community or Customer Community Plus as that changes how sharing is setup? – Dave Humm Nov 29 '16 at 0:24
  • Hi @DaveHumm, Thanks! The license type on the portal user is Customer Community Plus. – Shamir Colloff Nov 29 '16 at 0:43
  • hi @crmprogdev - thanks! I don't mind this being contact/contact (i.e., I am not wed to the account level) I just want a user to login and see "their" cases, regardless of how they are made. Does that make it any easier? Thanks!!! – Shamir Colloff Nov 29 '16 at 0:45
  • 1
    Yes, this is basically what you can do, keep in mind that this is a fragile approach since you bypass the sharing rulls of the org and if you have a bug in your code you could expose data... – Itai Shmida Nov 29 '16 at 19:38
0

I can tell you from experience that implementing Apex Managed Sharing in a Community Plus Org on Cases isn't something that's trivial. The solution for how best to do it is going to be unique to your particular use case. It's typically done asynchronously and not in real time for a number of reasons, most important of which is that the sharing tables will get recalculated which takes time.

In the implementations, I've done, typically when a new community user is created that meets the criteria you're going to use for sharing all the cases on an Account in your org. When the trigger fires after insert, typically those Id's are sent via an @future call to either a batch or queuable class where the related Accounts and all their related Cases are queried along with the sharing for them which is then granted to the new user. You can do this from within the trigger itself, but I recommend doing this asynchronously instead.

You'll also want your trigger to fire on After Update so the sharing is removed when a user is deactivated. Next, you'll also need a trigger on Cases that uses an @future call to a batchable or queuable to create the sharing for the community users when the record is created if it doesn't already exist. Since you'll likely have more than one user/account for a community, I would send every case to the batch class unless there's a reason you have not to do that.

A large part of why I recommend doing this asynchronously is because you have a Community Plus license, which means you likely have a very large number of users and will have a high volume of records that are constantly being created.

You can find more on Apex Managed Sharing in the Apex Developer Guide, including some sample code.

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.