I have a strange problem that I cannot figure out.

I have a database model that looks like this:

Database model

The A object is shared private in the org. User A creates record 1 and will become the automatically be owner of it. The "User" field will be set to User A. There is APEX sharing giving User B (user A's manager) read/write access to the object.

Both User A and User B is on the same profile and role and the profile has access to create, edit, update and delete to both object A and B (not "all"). When I look at the sharing records for record 1 I can see a R/W sharing rule for User B.

When logging in as User B I can edit record 1 without any problems. But when I try to delete it I get an permissions related error that I cannot explain.

First exception on row 0 with id XXXXXXXXXXXXXXXXXX; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []

(I've replaced the ID with X:es).

Any ideas what could cause this?

I am suspecting that Salesforce is removing the sharing in the delete process but cannot find any information about.

  • 1
    Do you have more relations in object A, and B? I think that you are trying to edit another object related with (A or B) by trigger, wf etc Thanks
    – Torsen
    Commented Apr 20, 2015 at 7:52
  • Thanks Torsen. Yes - in the database model yes. But not data wise - that means on record 1 there is no links to other objects - and there are no triggers / processes trying to update other object external to Object A.
    – haagen
    Commented Apr 20, 2015 at 7:55
  • Can you trying changing the trigger that insert the sharing role to accesslevel = All.
    – Torsen
    Commented Apr 20, 2015 at 7:58
  • 1
    Can you move the User B to a parent role of user A? IF you do this, the user B can see(edit,and delete) all the records of the user A.
    – Torsen
    Commented Apr 20, 2015 at 8:05

1 Answer 1


This was related to the role hierarchy. Since the users where on the same level in the role hierarchy the sharing rule would only give edit access and not delete access. To get delete access to a record you need to be either record owner, have "modify all data" or be over the user in the role hierarchy.

Read more here under the "User Managed Sharing, also known as Manual Sharing" section:


You must log in to answer this question.

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