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
Bryan Leaman 6Bryan Leaman 6 

Approval.unlock fails insufficient access to delete EntityLock

I'm trying to use the Approval.unlock and Approval.lock methods to allow specific updates to locked records, but I'm getting an error indicating my user is not authorized to delete records from EntityLock. How do I give someone access to delete EntityLock records? I don't see it in object authorities.

Op:Delete|Type:EntityLock|Rows:1
Delete failed. First exception on row 0 with id 04Z7e000000NUov; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []
 
VinayVinay (Salesforce Developers) 
Hi Bryan,

You will see error "INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id" because of Sharing Settings.

To overcome this issue, check the below

1. OWD, Sharing Rules and Role Hierarchy of the object in which you are trying to update the record.

2. Owner of the record which you are trying to update.

3. Check the trigger logic and check OWD, Sharing Rules and Role Hierarchy of the related objects records which are getting updated.

Note:
Even though trigger runs in System Mode, Sharing Settings will be checked. Only CRUD and FLS will not be checked against the user.

Thanks,
Bryan Leaman 6Bryan Leaman 6
It appears that when Apex code unlocks and re-locks a record, that new lock doesn't allow the current approver to edit the record anymore.  Looks like I cannot use Apex to unlock and re-lock records.