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
Ross Gilbert 31Ross Gilbert 31 

Not possible to hide a case from customers in a Salesforce community with Apex?

I understand sharing sets for communities and also sharing settings, org wide sharing settings, etc.  I understand that case visibility in a Salesforce community is controlled in Salesforce using hte Sharing Sets in the setup menu.  However the issue I have is, I want a community user to only see cases on their account where a custom field on the case is set to "true".  Cases where that flag is false should be hidden from that community user.

There is no way to do this through community sharing sets, nor through sharing settings, nor even apparently through the caseshare object and apex case sharing, because the community license is not suported for case sharing apparently.

Question: is it or is it not possible to hide a case from a community user in any way, based on that case having a checkbox field set to true.  If it is possible please point me in the direction that I can pursue to accomplish this, if you've done it, because it is looking to me to be something that cannot be done in Salesforce at this time from what I am seeing.  Thanks.
Ross Gilbert 31Ross Gilbert 31
Well if you built a totally custom community in visualforce you could not display cases that way with a custom controller, but that is not hiding he case really.  The community user, if he had the case id for example, could still access that case in your community, even though it might not show up on the visualforce page you create to show cases.

But we are intentionally not building a custom code community, because Salesforce's newer community templates are better and more robust and more scalable than building a community in code.  I have experiecne with those and they generally are a bad idea.

What do you suggest?
Ross Gilbert 31Ross Gilbert 31
We're using the Napili template for our community.  I'm having difficulty understanding your response.  As I see it right now, case sharing in a standard salesforce community is done through the communities sharing set.  This limits one to being able to expose cases that a community user's contact is assigned to, or his account is assigned to, or his entitlement is assigned to, etc.  But there is no way through these community sharing sets to hide/expose cases based on a custom case field value.  As I said, it appears to me that apex case sharing does not apply to community users.  So I see no way at all, in Salesforce, to hide a given case from a community user, when that case is on the account for the contact associated with that community user.  It simply does not look possible to me at this time.  But if there is a solution or even a possible solution you are aware of, without having to completely re-build a community in apex and visualforce, which is not an option and highly undesirable for multiple reasons, please let me know.