We had written a callout for auto sharing and unsharing of opportunity’s record for postassign event.
On creation of the record we were auto sharing the record with the owner’s manager.
On change of the owner we are first unsharing the record with the owner’s manager and sharing it with new owner’s manager.
While doing this the error we are receiving is this
“Only the owner of an object can revoke the owner’s access to that object “
This error is coming in this particular scenario
say we have a record shared with a particular user say A
now when we are trying to set the new owner as A what the code is trying to do is that,
it is trying to unshare the record with A this is the point where we receiving this error!!!
Lead record is owned by User A and is Shared with User A.
Now the Revoke code is running in context of User B and tries to run Revoke for User A who is the owner. We will get this error message.