0

Need recommendation regarding sharing a custom object(Relationship) records to community users:

We have a customer community accessible for community users(customer community license), the requirement is to display custom object records on a couple of community pages using custom LWC components and Apex code.

Now, I have two options to share the custom Object records -

  1. Set External OWD to "Private" and use apex class with "Without sharing" and use custom code to limit who will see what.(I am sure there is no standard community page exposed to users.)

  2. Set External OWD to "Public Read only" and use apex class with "with sharing" and custom code will make sure that user will access only records they need to see.

Please advise what is the recommended solution, my requirement can not be achieved by sharing set/groups at all.

1

For point no.1 : If you keep the OWD as private and your apex classes enforce "without sharing" then the sharing rules (for the current/end user) will not be enforced and the users can see only the records owned by them.

For point no.2 : If you keep the OWD as Public read only and if your apex classes enforce "with sharing" then the classes will run in user mode and will respect/enforce sharing rules/field level security and Object permissions. Therefore the records which you share to those users will only be visible along with the records the user owns.

I hope this clarifies and helps!!

1
  • 1
    No it's not true 1). if class is without sharing you can query the records as many as you want and can expose to LWC using wrapper class. – sunil gupta Dec 2 '20 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.