[SalesForce] Opportunity Access for customer community and customer community licenses

I can't show opportunity tab to customer community and customer community licenses users. And on the profile level there is no any option for this.

I read the documents and type of licenses and according to them opportunity is not available for user which these type of licenses.

But here I've two doubts

1) Here I have a controller and apex page. In controller I can get all the opportunities and all fetched opportunities are saved in wrapper class and then using a this wrapper class I can show opportunity and it is running successfully.

2) Here I have a controller and apex page. In controller I can get all the opportunities and saved in list and this list is a type of opportunity eg List<Opportunity> x. When I try to display oppty (using X) I got exception.

I am access my apex page from community portal.

My question if opportunity is not accessible to Customer portal and C Portal Licenses user the how can controller fetch the opportunities data ans show through the wrapper class and not opportunity type list.

Best Answer

I believe the answer to your question lies in the nature of a wrapper class. The wrapper class appears to Apex and the Community as an Object of Type that's something other than an Object that's of Type Opportunity. The class does not extend the Opportunity class nor is it an instance of Opportunity. So until you try to display a list of Type Opportunity, SF doesn't recognize that your wrapper class contains information that's not allowed to be displayed in your Customer Community.

In short, you might also say that its the same as permissions and sharing rules being applied at the time of display on a VF page. Its a simple case where Customer Community users don't have permission to view Opportunities because their license doesn't allow it.

The only way around this is to create a mirror object with Opportunities using a trigger to keep the object in sync. You can then display your custom mirror object records to your Customer Community Users. Otherwise, you'll need to purchase Partner Community Licenses.

Related Topic