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
Prit Kang 8Prit Kang 8 

salesforce community user record sharing

I have a custom object whose sharing setting is private. I want to share a record of this object with a community user but not being able to do so. Normally we have a "Share Object" (OBJECTNAME__Share) but I am unable to insert a record in this object. I would not like to give the view all permission on that particular object to the community user.

Is there a way this can be achieved

Thanks
Rajiv Penagonda 12Rajiv Penagonda 12
In most cases OBJECTNAME__Share will not be accessible to Portal users directly (SF does not say about Community users explicitly, I am assuming this is true there as well). If you are trying to run the apex code that is creating the OBJECTNAME__Share record in a Portal/Community user context, then try creating a utility class without sharing and run the sharing rules code from withing this utility function.

Without sharing clause would ensure all rules are ignored and code runs in system mode. Hope this help. Mark this as resolution if you find so.
Prit Kang 8Prit Kang 8
Thanks for the reply Rajiv.

I am running the apex code from a standard user (salesforce license) context. The error I get is FIELD_INTEGRITY_EXCEPTION : invalid user or group which i believe states that the user is not of correct type to insert a new record. without sharing is also not an option for us as it will be red flagged in the security review process.
 
Rajiv Penagonda 12Rajiv Penagonda 12
What kind of Object are you trying to share? Can you copy part of your code which is creating the OBJECTNAME__Share here?