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
sandeep@Salesforcesandeep@Salesforce 

How to a record with 'Delete' permission in apex ?

I have created a custom object with OWD private. Now I would like to sharing this record with a user X with 'Delete' permission.  What Accesslevel I need to use in order to create sharing record. 

Note: There is no Accesslevel called  'Delete'  exist. 
NagendraNagendra (Salesforce Developers) 
Hi Sandeep,
  • If your OWD for an Object is set to Private
  • Even if your user has READ, CREATE, EDIT access on that object, they won't be able to view records owned by others, just records they owned.
  • If they have VIEW ALL, then they can see other's records.
  • If they dont' have VIEW ALL Permission, but you want them to have access to see other user's record, just create a sharing rule to them or give them access through manual sharing. If you want specific users to have access but not all the user on the profile, just give the user Permission set which has View all data.
Also, if OWD=private, how can a user having VIEW ALL permission still see other records?

If your OWD = Private, only users with VIEW ALL permission on their profile can see records owned by others on that object. VIEW ALL Permission in profile is powerful as it gives VIEW access to ALL records on that object despite Private Sharing model on that object. 

if they only have Read, Create, Edit, delete but DON'T have VIEW ALL Permission, they can only READ and EDIT they're owned records. IF the "GRANT ACCESS USING HIERARCHIES" is checked on the sharing settings, users that don't have VIEW ALL permission can see other users record as long as those users are below them in the role hierarchy. 
Hope this helps.

Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra