1

My org has External Sharing Model enabled. It has Custom object with Default External Access set to Private.

enter image description here

Now I need that custom object to be shared with (read access) all users in specific profile.

Since the user is Customer Community Plus, I'm unable to set View All permission on object level. Sharing rule can't be use with a profile.

missing view all permission

How do i achive this requirement ?

1
  • I think you will need to look at Apex sharing for this. If nobody else puts up an answer I might be able to dig up an example of the code to do this.
    – Dave Humm
    Commented Oct 9, 2017 at 8:58

2 Answers 2

2

I could able to solve this by adding users into separate public group and share records using sharing rule.

Sample code for adding users dynamically to a public group can be found in here - Trigger to add active user with standard profile to public group

1

You can do this by having an Apex trigger to use Apex managed sharing as you are using Customer Community Plus users.

The documentation on this is here.

To sum up what you have to do is have an after trigger for insert and update of records on the custom object that will share to the users in that specific profile. It needs to be an after trigger so that the record Id is available to use in the sharing record as it will create a sharing record for each record in the custom object.

It may be best to add all the users with that profile to a group which the records are then shared to as this will be simpler than sharing to individual users.

3
  • 1
    I'll add some example code later, but see my old question salesforce.stackexchange.com/questions/157072/… for a starter as well as the SF docs
    – Dave Humm
    Commented Oct 9, 2017 at 9:22
  • Thanks Dave. In the documentation it says Share objects isn't available for community plus users. Do you know what that means ?developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…
    – ChamingaD
    Commented Oct 10, 2017 at 2:57
  • 1
    That means that a community plus user is not able to manually share a record which I've not come across a use case that needs it. The apex trigger means that a share is created by running in system mode so permissions are not an issue.
    – Dave Humm
    Commented Oct 10, 2017 at 8:26

You must log in to answer this question.

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