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
kurtz_wolfgangkurtz_wolfgang 

Apex Managed Sharing Problem

Hello All,

 

  I am having some problems with Apex Managed Sharing. Following is the scenario:

 

- Custom object call has org. wide setting to Private. All the records in it are owned by only the System admin. The records are imported using ETL.

- For a specific value in a field site, different set of users should get access. Apex managed sharing code in a trigger gives read access for new data coming in to SFDC. For old data, I have a batch apex job which does the same. 

- I see that the users have read access, checked the share object. But when I access that record with that users' creds, I get the error - Insufficient Privileges.

- On additional note, for profile of each of those users, Call object access is - NO Access. 

 

I would appreciate if anybody can point out what's wrong in the whole situation or what can be the possible solution.

 

I would be grateful for any pointers.

 

Thank you 

KB.

Best Answer chosen by Admin (Salesforce Developers) 
kurtz_wolfgangkurtz_wolfgang

I had to give private access at OWD and read access to the objects at the (custom) profile. Additionally my code had a bug. Apparently Apex doesnt give an error when you add two values with the same key into a map and it will only retrieve first value that was inserted, which is weird.

 

But Thanks for that suggestion, I wouldn't have thought of it right away.

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

I think you are using the Salesforce Standard Profile that’s why you are unable to give the permission to custom object on that profile. So first off all you have to clone that profile with Name Standard Platform Clone and Give the Desired permission on your custom Object on that profile(don’t give the permission like view all and modify all). Now assign this profile to that user whom you want to share the records through trigger.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

kurtz_wolfgangkurtz_wolfgang

I had to give private access at OWD and read access to the objects at the (custom) profile. Additionally my code had a bug. Apparently Apex doesnt give an error when you add two values with the same key into a map and it will only retrieve first value that was inserted, which is weird.

 

But Thanks for that suggestion, I wouldn't have thought of it right away.

This was selected as the best answer