[SalesForce] Transfer lead ownership when lead object is private

I am having issues trying to allow users with the same profile and role to change ownership of records amongst themselves with leads. The lead object is set to private. Their profile has transfer leads and transfer records and create,read,edit,view all permissions on the lead object.

So, when a user with the same profile and role accesses another user's lead record with the same role and profile and tries to change the ownership, it is giving an insufficient privileges error. Is the only way to allow the user to transfer the ownership thru apex code with a custom button using without sharing? I was hoping this could be done declaratively.

Best Answer

If Lead object is Private in OWD then only record owner will have full access to the record. Only record owner or users above the Role Hierarchy can transfer the ownership of the record.

For other users with Modify All permission can only transfer the ownership of other user's record, otherwise System will throw error - Insufficient Privileges.

Salesforce sharing and privileges works same way as through UI or by API if it runs in User mode. If something that cannot be done through UI, same thing cannot be done through API or coding until and unless it runs in system mode.