0

Scenario:

  • We have a client portal enabled using Napili communities. They use ‘Customer Community Login User’ license.
  • We also have another set of users who use are supervisors and they also use the community.They use ‘Customer Community Plus’ license.
  • There is a screen in which the client picks Accounts to share data with and what we wanted to do is to give access to the citizens account and a group.
  • A group of supervisors with a special permission are added to a public group which is specific for each account and when the citizen agrees to share data with the account they see the relevant client data.
  • We tried to provide access to the Citizens Account to the Supervisors account group. When any supervisor is added to the group they will get access to the client information Since Contact is a child of account in our setup(controlled by parent).

In my apex controller when I used with sharing mode and tried to insert account share I get the error the `

field account id is not writeable

If I make the class without sharing based on this documentation, I get the below error.The same code works if i anonymous execute it from an admin user.

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

It looks to me that AccountShare object is not available for HVPU users. Hoping someone proves me wrong

Workarounds or alternate solutions tried:

  1. For communities we can create sharing groups and add roles/groups to it, we tried adding high volume customer portal group and the supervisors were able to view client information, The flipside to this is every account can see each other’s data. We have to put additional conditions in SOQL to ensure they only their account related clients
  2. Instead of inserting record into AccountShare through the community user we inserted the data into a custom object and then used a schedulable batch class which runs every 5 mins(suicide scheduling) to insert records into AccountShare table based on data in the custom object
  3. Using an apex rest service to hit your own org and create the AccountShare using as integration user

Is there any other way or better solution to this problem or am I making a mistake in the sharing configuration which is resulting in this issue?

There is already another stack exchange Question with the same problem but since I tried few solutions I wanted to consolidate everything to check for better solutions.

2
  • Which user is trying to insert the AccountShare record -- the citizen user or the supervisor user? And to clarify -- for the supervisor users, you are trying to give them access to the citizen user's account record? Commented Nov 28, 2017 at 0:36
  • Your stackexchange Question link doesn't link to anything. Is this the question you were referring to? Commented Nov 28, 2017 at 0:45

1 Answer 1

1

AccountShare, ContactShare objects are not available for Customer Portal users..

Refer Creating Apex Managed Sharing for Customer Community Plus users

Customer Community Plus users are previously known as Customer Portal users. Share objects, such as AccountShare and ContactShare, aren’t available to these users. If you must use share objects as a Customer Community Plus user, consider using a trigger, which operates with the without sharing keyword by default. Otherwise, use an inner class with the same keyword to enable the DML operation to run successfully. A separate utility class can also be used to enable this access.

Granting visibility via manual/apex shares written to the share objects is supported but the objects themselves aren't available to Customer Community Plus users. However, other users can add shares that grant access to Customer Community Plus users.

High Volume Customer Portal (HVPU) license users (including Community and Service Cloud license users) do not utilize the sharing model. HVPU licenses have their own sharing model that works by foreign key match between the portal user (holding the license) and the data on Account and Contact lookups.

I could say, according to your use, you are in right direction.

1
  • Thanks Santanu. If you look at the second line from the documentation you provided '. If you must use share objects as a Customer Community Plus user, consider using a trigger, which operates with the without sharing keyword by default', I tried a without sharing class and even that did not work. Thats where i am confused.Is it supposed to work and not working because i am doing it wrong?
    – RedDevil
    Commented Jul 22, 2017 at 6:38

You must log in to answer this question.

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