- 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.
It looks to me that AccountShare object is not available for HVPU users. Hoping someone proves me wrong
Workarounds or alternate solutions tried:
- 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
- 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
- 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.